DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Namespaces | Classes | Typedefs | Functions | Variables
dd4hep::xml Namespace Reference

Namespace for the AIDA detector description toolkit supporting XML utilities. More...

Namespaces

 cond
 Namespace of conditions unicode tags.
 
 tools
 Declaration of the XML tools namespace.
 

Classes

class  Collection_t
 Class to support the access to collections of XmlNodes (or XmlElements) More...
 
class  Document
 Class supporting the basic functionality of an XML document. More...
 
class  DocumentErrorHandler
 XML-DOM ERror handler class for the XercesC document parser. More...
 
class  DocumentHandler
 Class supporting to read and parse XML documents. More...
 
class  DocumentHolder
 Class supporting the basic functionality of an XML document including ownership. More...
 
class  Element
 User abstraction class to manipulate XML elements within a document. More...
 
class  Handle_t
 Class to easily access the properties of single XmlElements. More...
 
class  LayeringCnv
 XML converter for layering objects. More...
 
class  NodeList
 Class describing a list of XML nodes. More...
 
class  RefElement
 User abstraction class to manipulate named XML elements (references) within a document. More...
 
class  Strng_t
 Helper class to encapsulate a unicode string. More...
 
class  Tag_t
 Class to support both way translation between C++ and XML strings. More...
 
class  UriContextReader
 Class supporting to read data given a URI. More...
 
class  UriReader
 Class supporting to read data given a URI. More...
 
class  XmlString
 Definition of the XmlString class. More...
 

Typedefs

typedef std::size_t XmlSize_t
 
typedef XERCES_XMLCH_T XmlChar
 Use the definition from the autoconf header of Xerces: More...
 
typedef const XmlAttr * Attribute
 
typedef const std::string & CSTR
 
typedef const XmlCharcpXmlChar
 
typedef xercesc::DOMException XmlException
 

Functions

Transform3D createTransformation (xml::Element element)
 Create layered transformation from xml information. More...
 
Volume createStdVolume (Detector &description, xml::Element element)
 Create a simple volume using the shape plugin mechanism from the attributes of the XML element. More...
 
Volume createVolume (Detector &description, const std::string &type, xml::Element element)
 Create a volume using the plugin mechanism from the attributes of the XML element. More...
 
Solid createShape (Detector &description, const std::string &shape_type, xml::Element element)
 Create a solid shape using the plugin mechanism from the attributes of the XML element. More...
 
Volume createPlacedEnvelope (dd4hep::Detector &description, dd4hep::xml::Handle_t e, dd4hep::DetElement sdet)
 
void setDetectorTypeFlag (dd4hep::xml::Handle_t e, dd4hep::DetElement sdet)
 
std::size_t configVolume (dd4hep::Detector &detector, dd4hep::xml::Handle_t element, dd4hep::Volume volume, bool propagate, bool ignore_unknown_attr=false)
 Configure volume properties from XML element. More...
 
std::size_t configSensitiveDetector (dd4hep::Detector &detector, dd4hep::SensitiveDetector sensitive, dd4hep::xml::Handle_t element)
 Configure sensitive detector from XML element. More...
 
void dumpTree (XmlDocument *doc)
 Dump DOM tree of a document. More...
 
int set_float_precision (int precision)
 Change floating point precision on conversion to string. More...
 
int get_float_precision ()
 Access floating point precision on conversion to string. More...
 
std::string _toString (const Attribute attr)
 Convert xml attribute to STL string. More...
 
std::string _toString (const XmlChar *toTranscode)
 Convert xml string to STL string. More...
 
std::string _toString (const char *s)
 Do-nothing version. Present for completeness and argument interchangeability. More...
 
std::string _toString (const std::string &s)
 Do-nothing version. Present for completeness and argument interchangeability. More...
 
std::string _toString (unsigned long i, const char *fmt="%lu")
 Format unsigned long integer to string with arbitrary format. More...
 
std::string _toString (unsigned int i, const char *fmt="%u")
 Format unsigned integer (32 bits) to string with arbitrary format. More...
 
std::string _toString (int i, const char *fmt="%d")
 Format signed integer (32 bits) to string with arbitrary format. More...
 
std::string _toString (long i, const char *fmt="%ld")
 Format signed long integer to string with arbitrary format. More...
 
std::string _toString (float d, const char *fmt="%.17e")
 Format single procision float number (32 bits) to string with arbitrary format. More...
 
std::string _toString (double d, const char *fmt="%.17e")
 Format double procision float number (64 bits) to string with arbitrary format. More...
 
std::string _ptrToString (const void *p, const char *fmt="%p")
 Format void pointer (64 bits) to string with arbitrary format. More...
 
template<typename T >
std::string _toString (const T *p, const char *fmt="%p")
 Format void pointer (64 bits) to string with arbitrary format. More...
 
void _toDictionary (const XmlChar *name, const XmlChar *value)
 Helper function to populate the evaluator dictionary. More...
 
template<typename T >
void _toDictionary (const XmlChar *name, T value)
 Helper function to populate the evaluator dictionary. More...
 
void _toDictionary (const XmlChar *name, float value)
 Helper function to populate the evaluator dictionary. More...
 
void _toDictionary (const XmlChar *name, double value)
 Helper function to populate the evaluator dictionary. More...
 
bool _toBool (const XmlChar *value)
 Conversion function from raw unicode string to bool. More...
 
int _toInt (const XmlChar *value)
 Conversion function from raw unicode string to int. More...
 
unsigned int _toUInt (const XmlChar *value)
 Conversion function from raw unicode string to unsigned int. More...
 
long _toLong (const XmlChar *value)
 Conversion function from raw unicode string to long. More...
 
unsigned long _toULong (const XmlChar *value)
 Conversion function from raw unicode string to unsigned long. More...
 
float _toFloat (const XmlChar *value)
 Conversion function from raw unicode string to float. More...
 
double _toDouble (const XmlChar *value)
 Conversion function from raw unicode string to double. More...
 
std::string getEnviron (const std::string &env)
 Helper function to lookup environment from the expression evaluator. More...
 
bool enableEnvironResolution (bool new_value)
 Enable/disable environment resolution when parsing strings. More...
 
Strng_t operator+ (const Strng_t &a, const char *b)
 Unicode string concatenation of a normal ASCII string from right side. More...
 
Strng_t operator+ (const Strng_t &a, const std::string &b)
 Unicode string concatenation of a encapsulated and an STL string from right side. More...
 
Strng_t operator+ (const Strng_t &a, const Strng_t &b)
 Unicode string concatenation of a encapsulated and an encapsulated string from right side. More...
 
Strng_t operator+ (const char *a, const Strng_t &b)
 Unicode string concatenation of a normal ASCII string from left side. More...
 
Strng_t operator+ (const std::string &a, const Strng_t &b)
 Unicode string concatenation of a STL string and an encapsulated string from the left. More...
 
Strng_t operator+ (const Strng_t &a, const XmlChar *b)
 Unicode string concatenation of a encapsulated and raw unicode string from right side. More...
 
Strng_t operator+ (const XmlChar *a, const Strng_t &b)
 Unicode string concatenation of a encapsulated and raw unicode string from left side. More...
 
Strng_t operator+ (const XmlChar *a, const std::string &b)
 Unicode string concatenation of a raw unicode and an STL string from the right. More...
 
Strng_t operator+ (const std::string &a, const XmlChar *b)
 Unicode string concatenation of a raw unicode and an STL string from the left. More...
 
Tag_t operator+ (const Tag_t &a, const char *b)
 Tag/string concatenation with a normal ASCII string from right side. More...
 
Tag_t operator+ (const char *a, const Tag_t &b)
 Tag/string concatenation with a normal ASCII string from left side. More...
 
Tag_t operator+ (const Tag_t &a, const XmlChar *b)
 Tag/string concatenation with a unicode string from right side. More...
 
Tag_t operator+ (const Tag_t &a, const Strng_t &b)
 Tag/string concatenation with a internal Xml string from right side. More...
 
Tag_t operator+ (const Tag_t &a, const std::string &b)
 Tag/string concatenation with a STL string from right side. More...
 
bool operator== (const std::string &c, const Tag_t &b)
 Equality operator between tag object and STL string. More...
 
std::string _toString (const Strng_t &s)
 Convert Strng_t to std::string. More...
 
std::string _toString (const Tag_t &s)
 Convert Tag_t to std::string. More...
 
void _toDictionary (const XmlChar *name, const Strng_t &s)
 Helper function to populate the evaluator dictionary. More...
 
void _toDictionary (const XmlChar *name, const Tag_t &t)
 Helper function to populate the evaluator dictionary. More...
 
template<>
INLINE std::string Handle_t::attr< std::string > (const XmlChar *tag_value) const
 
template<>
INLINE std::string Handle_t::attr< std::string > (const XmlChar *tag_value, std::string default_value) const
 
void dump_tree (Handle_t elt)
 Dump partial or full XML trees to stdout. More...
 
void dump_tree (Handle_t elt, std::ostream &os)
 Dump partial or full XML trees. More...
 
void dump_tree (Document doc)
 Dump partial or full XML documents to stdout. More...
 
void dump_tree (Document doc, std::ostream &os)
 Dump partial or full XML documents. More...
 
bool setXMLParserDebug (bool new_value)
 Set debug print level for this module. Default is OFF. More...
 
void parse (Handle_t e, RotationZYX &rot)
 Convert rotation XML objects to dd4hep::RotationZYX. More...
 
void parse (Handle_t e, Position &pos)
 Convert XML position objects to dd4hep::Position. More...
 
void parse (Handle_t e, Translation3D &tr)
 Convert XML pivot objects to dd4hep::Translation3D objects. More...
 
void parse (Handle_t e, Delta &delta)
 Convert alignment delta objects to Delta. More...
 
void parse_delta (Handle_t e, OpaqueDataBlock &block)
 Parse delta into an opaque data block. More...
 
void parse_mapping (Handle_t e, OpaqueDataBlock &block)
 Converts opaque maps to OpaqueDataBlock objects. More...
 
void parse_sequence (Handle_t e, OpaqueDataBlock &block)
 Converts linear STL containers from their string representation. More...
 
void dumpTree (DOMNode *doc, std::ostream &os)
 Dump DOM tree using XercesC handles. More...
 
void dump_doc (DOMDocument *doc, std::ostream &os)
 Dump DOM tree using XercesC handles. More...
 
void tags_init ()
 

Variables

const Tag_t Unicode_NULL ("NULL", "0", __Init::register_tag)
 
const Tag_t Unicode_empty ("", "", __Init::register_tag)
 
const Tag_t Unicode_star ("star", "*", __Init::register_tag)
 
const Tag_t Unicode_PI ("PI", "3.14159265358979323846", __Init::register_tag)
 
const Tag_t Unicode_TWOPI ("TWOPI", "6.28318530717958647692", __Init::register_tag)
 

Detailed Description

Namespace for the AIDA detector description toolkit supporting XML utilities.

Namespace containing utilities to parse XML files using XercesC or TinyXML.

Typedef Documentation

◆ Attribute

typedef const XmlAttr* dd4hep::xml::Attribute

Definition at line 38 of file XMLElements.h.

◆ cpXmlChar

Definition at line 526 of file XMLElements.h.

◆ CSTR

typedef const std::string& dd4hep::xml::CSTR

Definition at line 95 of file XMLElements.h.

◆ XmlChar

typedef XERCES_XMLCH_T dd4hep::xml::XmlChar

Use the definition from the autoconf header of Xerces:

Definition at line 53 of file config.h.

◆ XmlException

typedef xercesc::DOMException dd4hep::xml::XmlException

Definition at line 53 of file DetectorImp.cpp.

◆ XmlSize_t

typedef std::size_t dd4hep::xml::XmlSize_t

Definition at line 48 of file config.h.

Function Documentation

◆ _toString() [1/2]

std::string dd4hep::xml::_toString ( const Strng_t s)

Convert Strng_t to std::string.

Definition at line 301 of file XMLElements.cpp.

◆ _toString() [2/2]

std::string dd4hep::xml::_toString ( const Tag_t s)

Convert Tag_t to std::string.

Definition at line 306 of file XMLElements.cpp.

◆ configSensitiveDetector()

std::size_t dd4hep::xml::configSensitiveDetector ( dd4hep::Detector detector,
dd4hep::SensitiveDetector  sensitive,
dd4hep::xml::Handle_t  element 
)

Configure sensitive detector from XML element.

Example: <some-xml-tag debug="true"> <combine_hits value="true"> <verbose value="true"> <type value="tracker"> <ecut value="5*keV"> <hits_collection value="hits_collection_5"> </some-xml-tag>

  • The debug flag is optional.
  • Not all child nodes are mandatory. If not present, the attribute stays unchanged.
Returns
Number of properties changed
Author
M.Frank
Version
1.0
Date
03.03.23

Definition at line 378 of file Utilities.cpp.

◆ configVolume()

std::size_t dd4hep::xml::configVolume ( dd4hep::Detector detector,
dd4hep::xml::Handle_t  element,
dd4hep::Volume  volume,
bool  propagate,
bool  ignore_unknown_attr = false 
)

Configure volume properties from XML element.

Example: <volume> <regionref name="world_region"> <limitsetref name="world_limits"> <visref name="world_vis"> </volume>

with dd4hep::Detector& detector: Handle to dd4hep Detector instance dd4hep::xml::Handle_t element: XML element <volume> dd4hep::Volume volume: the volume to be configured. bool propagate: apply setting also to all children bool ignore_unknown_attr: Ignore unknown attrs

Returns
Number of properties changed
Author
M.Frank
Version
1.0
Date
03.03.23

Definition at line 331 of file Utilities.cpp.

◆ createPlacedEnvelope()

dd4hep::Volume dd4hep::xml::createPlacedEnvelope ( dd4hep::Detector description,
dd4hep::xml::Handle_t  e,
dd4hep::DetElement  sdet 
)

Create an envelope volume that is placed into the world volume (the parent volume of sdet) from an xml element <envelope/> with child nodes <shape/> and optionally <position/> and <rotation/>. For special cases no volume but an assembly can be created with <shape type="Assembly"/>. Example:

<envelope vis="ILD_ECALVis">
<shape type="PolyhedraRegular" numsides="8"  rmin="TPC_outer_radius+Ecal_Tpc_gap" rmax="Ecal_outer_radius"
dz="2.*TPC_Ecal_Hcal_barrel_halfZ"  material = "Air" />
<rotation x="0*deg" y="0*deg" z="90*deg-180*deg/8"/>
</envelope>
Author
S.Lu DESY, F. Gaede CERN/DESY

Definition at line 220 of file Utilities.cpp.

◆ createShape()

dd4hep::Solid dd4hep::xml::createShape ( Detector description,
const std::string &  shape_type,
xml::Element  element 
)

Create a solid shape using the plugin mechanism from the attributes of the XML element.

Definition at line 84 of file Utilities.cpp.

◆ createStdVolume()

dd4hep::Volume dd4hep::xml::createStdVolume ( Detector description,
xml::Element  element 
)

Create a simple volume using the shape plugin mechanism from the attributes of the XML element.

Create a volume using the plugin mechanism from the attributes of the XML element.

Trigger on:

<volume name="..." type="Assembly"> or <volume name="..." material="Air">

<shape .... /> or <volume .... />

optional: <position x="0" ... /> <rotation x="0" ... /> </volume>

Trigger on:

  • typical for CAD multi-volume shapes

<shape name="Assembly" type="Assembly"> <shape .... /> <position x="0" ... /> <rotation x="0" ... /> </shape>

Definition at line 100 of file Utilities.cpp.

◆ createTransformation()

dd4hep::Transform3D dd4hep::xml::createTransformation ( xml::Element  element)

Create layered transformation from xml information.

The xml content of the information supposedly looks like this: <transformation> <position> <rotation x="-90*degree"> <position> <rotation y="-90*degree"> <position x="CutX" y=" 0.5*YokeHorHeight" z="-0.5*(YokeHorD1+YokeHorA1)"> <rotation x="-HoleAngle"> <position> <rotation z="CutTrapTheta"> </transformation>

Every pair position, rotation will be combined to a Transform3D and combined to the resulting transformation.

Definition at line 42 of file Utilities.cpp.

◆ createVolume()

dd4hep::Volume dd4hep::xml::createVolume ( Detector description,
const std::string &  type,
xml::Element  element 
)

Create a volume using the plugin mechanism from the attributes of the XML element.

Definition at line 197 of file Utilities.cpp.

◆ dump_doc()

void dd4hep::xml::dump_doc ( DOMDocument *  doc,
std::ostream &  os 
)

Dump DOM tree using XercesC handles.

Definition at line 236 of file DocumentHandler.cpp.

◆ dump_tree() [1/4]

void dd4hep::xml::dump_tree ( Document  doc)

Dump partial or full XML documents to stdout.

Definition at line 704 of file DocumentHandler.cpp.

◆ dump_tree() [2/4]

void dd4hep::xml::dump_tree ( Document  doc,
std::ostream &  os 
)

Dump partial or full XML documents.

Dump DOM tree using XercesC handles.

Definition at line 244 of file DocumentHandler.cpp.

◆ dump_tree() [3/4]

void dd4hep::xml::dump_tree ( Handle_t  elt)

Dump partial or full XML trees to stdout.

Definition at line 699 of file DocumentHandler.cpp.

◆ dump_tree() [4/4]

void dd4hep::xml::dump_tree ( Handle_t  elt,
std::ostream &  os 
)

Dump partial or full XML trees.

Dump DOM tree using XercesC handles.

Definition at line 240 of file DocumentHandler.cpp.

◆ dumpTree() [1/2]

void dd4hep::xml::dumpTree ( DOMNode *  doc,
std::ostream &  os 
)

Dump DOM tree using XercesC handles.

Definition at line 218 of file DocumentHandler.cpp.

◆ dumpTree() [2/2]

void dd4hep::xml::dumpTree ( XmlDocument *  doc)

Dump DOM tree of a document.

◆ enableEnvironResolution()

bool dd4hep::xml::enableEnvironResolution ( bool  new_value)

Enable/disable environment resolution when parsing strings.

Definition at line 408 of file XMLElements.cpp.

◆ get_float_precision()

int dd4hep::xml::get_float_precision ( )

Access floating point precision on conversion to string.

Definition at line 229 of file XMLElements.cpp.

◆ getEnviron()

std::string dd4hep::xml::getEnviron ( const std::string &  env)

Helper function to lookup environment from the expression evaluator.

Evaluate string constant using environment stored in the evaluator.

Definition at line 403 of file XMLElements.cpp.

◆ Handle_t::attr< std::string >() [1/2]

template<>
INLINE std::string dd4hep::xml::Handle_t::attr< std::string > ( const XmlChar tag_value) const

Definition at line 564 of file XMLElements.h.

◆ Handle_t::attr< std::string >() [2/2]

template<>
INLINE std::string dd4hep::xml::Handle_t::attr< std::string > ( const XmlChar tag_value,
std::string  default_value 
) const

Definition at line 608 of file XMLElements.h.

◆ parse() [1/4]

void dd4hep::xml::parse ( Handle_t  e,
Delta delta 
)

Convert alignment delta objects to Delta.

A generic alignment transformation is defined by

  • a translation in 3D space identified in XML as a <position> element
    • a rotation in 3D space around a pivot point specified in XML by 2 elements: the <rotation> and the <pivot> element. The specification of any of the elements is optional:
  • The absence of a translation implies the origine (0,0,0)
  • The absence of a pivot point implies the origine (0,0,0)

    • The absence of a rotation implies the identity rotation. Any supplied pivot point in this case is ignored.

    <xx> <position x="0" y="0" z="0.0001*mm"> <rotation x="0" y="0" z="0"> <pivot x="0" y="0" z="100"> </xx>

Author
M.Frank
Version
1.0
Date
01/04/2014

Definition at line 73 of file XMLParsers.cpp.

◆ parse() [2/4]

void dd4hep::xml::parse ( Handle_t  e,
Position pos 
)

Convert XML position objects to dd4hep::Position.

<position x="0.5" y="0" z="0"> => dd4hep::Position

Author
M.Frank
Version
1.0
Date
01/04/2014

Definition at line 57 of file XMLParsers.cpp.

◆ parse() [3/4]

void dd4hep::xml::parse ( Handle_t  e,
RotationZYX rot 
)

Convert rotation XML objects to dd4hep::RotationZYX.

<rotation x="0.5" y="0" z="0"> => dd4hep::RotationZYX

Author
M.Frank
Version
1.0
Date
01/04/2014

Definition at line 48 of file XMLParsers.cpp.

◆ parse() [4/4]

void dd4hep::xml::parse ( Handle_t  e,
Translation3D tr 
)

Convert XML pivot objects to dd4hep::Translation3D objects.

<pivot x="0.5" y="0" z="0">

Author
M.Frank
Version
1.0
Date
01/04/2014

Definition at line 65 of file XMLParsers.cpp.

◆ parse_delta()

void dd4hep::xml::parse_delta ( Handle_t  e,
OpaqueDataBlock block 
)

Parse delta into an opaque data block.

See void parse(Handle_t e, Delta& delta) for details.

Author
M.Frank
Version
1.0
Date
01/04/2014

Definition at line 99 of file XMLParsers.cpp.

◆ parse_mapping()

void dd4hep::xml::parse_mapping ( Handle_t  e,
OpaqueDataBlock block 
)

Converts opaque maps to OpaqueDataBlock objects.

Opaque data mappings are formalized std::map objects (or std::hash_map etc.) where the data source is parsed into the map using boost::spirit as a data interpretation mechanism.

Author
M.Frank
Version
1.0
Date
01/04/2014

Definition at line 105 of file XMLParsers.cpp.

◆ parse_sequence()

void dd4hep::xml::parse_sequence ( Handle_t  e,
OpaqueDataBlock block 
)

Converts linear STL containers from their string representation.

Opaque data sequences are formalized linear STL container objects (std::vector, std::list, std::set, std::deque etc.) where the data source is parsed into the map using boost::spirit as a data interpretation mechanism.

Author
M.Frank
Version
1.0
Date
01/04/2014

Definition at line 125 of file XMLParsers.cpp.

◆ set_float_precision()

int dd4hep::xml::set_float_precision ( int  precision)

Change floating point precision on conversion to string.

Definition at line 222 of file XMLElements.cpp.

◆ setDetectorTypeFlag()

void dd4hep::xml::setDetectorTypeFlag ( dd4hep::xml::Handle_t  e,
dd4hep::DetElement  sdet 
)

Sets the type flag specified in the <type_flags> element for the given DetElement, example:

<type_flags type=" DetType_TRACKER + DetType_PIXEL + DetType_VERTEX "/>
Author
F.Gaede, DESY

Definition at line 284 of file Utilities.cpp.

◆ setXMLParserDebug()

bool dd4hep::xml::setXMLParserDebug ( bool  new_value)

Set debug print level for this module. Default is OFF.

Set debug level for this module. Default is OFF.

Definition at line 41 of file XMLParsers.cpp.

◆ tags_init()

void dd4hep::xml::tags_init ( )

Definition at line 82 of file XMLTags.cpp.

Variable Documentation

◆ Unicode_empty

const Tag_t dd4hep::xml::Unicode_empty("", "", __Init::register_tag)

◆ Unicode_NULL

const Tag_t dd4hep::xml::Unicode_NULL("NULL", "0", __Init::register_tag)

◆ Unicode_PI

const Tag_t dd4hep::xml::Unicode_PI("PI", "3.14159265358979323846", __Init::register_tag)

◆ Unicode_star

const Tag_t dd4hep::xml::Unicode_star("star", "*", __Init::register_tag)

◆ Unicode_TWOPI

const Tag_t dd4hep::xml::Unicode_TWOPI("TWOPI", "6.28318530717958647692", __Init::register_tag)