Geometry Management Based on DD4hep

DD4hep adopts the design principle of a single geometric definition source, providing a mechanism for defining detector geometry, materials, detector readout, and sensitive regions based on XML. Detector designers can describe all geometric elements, materials, positions, and optical properties of the detector based on its structure and this set of rules in an XML file. On this basis, developers can write C++ and Python code to assist in parsing the XML file, completing tasks such as copying and stacking detector units and defining the encoding rules for detector units.

DD4hep uses the TGeo object provided by ROOT as the unified format for storing geometry in memory. Based on the TGeo object, DD4hep provides various plugins to support converting TGeo format geometry to various formats required by applications, such as the DDG4 plugin for converting geometry to the Geant4 G4VPhysicalVolume format, the GDML plugin for converting geometry to GDML files, the DDG4 plugin for converting geometry to a format required by reconstruction software, and the DDEve plugin for displaying detector geometry. In addition, as detector calibration data changes over time and is typically stored in a database, DD4hep also provides an interface to access the state database (conditions DB) to adjust the geometric structure based on the stored calibration data in memory.

This design architecture ensures that all data processing software and geometry and event display software use the same geometric source, fundamentally guaranteeing geometric consistency. Additionally, whenever detector geometry needs to be updated, it only needs to be updated from the XML source, which can greatly reduce the workload.

Fig. DD4hep Design Scheme

Because the HERD detector is divided into multiple subdetectors, such as SCD, FIT, PSD, TRD, and calorimeter, which are designed by different developers, the HERDOS geometry management system adopts a hierarchical geometry definition: defining the geometry of each subdetector in different XML files, defining common information such as elements and materials in a common XML file, and finally combining all the subXML files into a single file, which is parsed by DD4hep to generate geometry.

HERDOS geometric management system implements multi-version geometric management. Developers can define multiple versions of XML files for subdetectors according to their needs, define a unique version number for each file, and select the geometric version of each subdetector during final assembly. This allows for switching between geometric versions without recompiling the software.

Fig. HERDOS Geometry Definition based on XML