Warning, /acts/docs/plugins/dd4hep.md is written in an unsupported language. File is not indexed.
0001 # DD4hep plugin
0002
0003 :::{todo}
0004 Describe new markup and construction for DD4hep plugin and building layerless geometry.
0005 :::
0006
0007 The DD4hepPlugin allows building of a {class}`Acts::TrackingGeometry` from
0008 [DD4hep](https://dd4hep.web.cern.ch/dd4hep/) input. DD4hep uses [ROOT](https://root.cern.ch) TGeo as the underlying geometry model.
0009
0010 :::{note}
0011 Previous versions of ACTS (prior to `v20.0.0`) used a different integration
0012 mechanism. Please refer to the documentation of prior versions for more information.
0013 :::
0014
0015 ## General
0016
0017 The basic input for building the detector are a detector description in the
0018 XML file format and a corresponding detector constructor written in C++. These
0019 two components have to be changed accordingly. Detector constructors use these
0020 XML files as an input and construct a detector in the DD4hep geometry format.
0021 The whole detector is segmented into different detector parts, e.g. barrels
0022 and endcaps which describe different sub-detectors. Since these sub-detectors
0023 are built differently, they need different detector constructors. In this way
0024 one detector description in XML can use various detector constructors, needed
0025 for the different kinds of detector parts.
0026
0027 In the detector description model of DD4hep any detector is a tree of instances
0028 of the so-called `DetElement` class. This `DetElement` class provides all
0029 needed detector information, e.g. readout segmentation, geometrical information,
0030 environmental conditions. This tree is parallel to the volume tree, which
0031 provides the `TGeoVolumes` and their placements. The relation between these
0032 two trees is one-directional, i.e. every volume can be accessed via its
0033 corresponding `DetElement`, but not vice versa. Not every supporting material
0034 will be declared as a detector element, hence, the geometrical tree can have a
0035 deeper hierarchy structure. In order to access both, detector specific and
0036 geometrical information, the conversion to the tracking geometry navigates
0037 through the detector tree. The `DetElement` can also be extended, to add
0038 specific features or to access information. This extension mechanism is used
0039 during the translation process.
0040
0041 The ACTS DD4hep plugin inspects the geometry hierarchy and searches for
0042 sensitive detector elements and passive material structures. ACTS identifies
0043 relevant parts of the detector by DD4hep's `DetType` (see
0044 [documentation](https://dd4hep.web.cern.ch/dd4hep/reference/classdd4hep_1_1DetType.html#ae353f4bccf0f288793526efa10866af2)),
0045 which can be set from XML. ACTS will attempt to translate detector elements
0046 marked as `DetType::TRACKER`. `DetType::BARREL` and `DetType::ENDCAP` tell ACTS
0047 to convert a detector element as a sensitive volume, while the beampipe is
0048 identified by `DetType::BEAMPIPE`.
0049
0050 In addition, ACTS looks for specific markup that can be attached to
0051 detector elements via XML or from the experiment specific geometry driver /
0052 factory.
0053
0054 ## ACTS specific markup
0055
0056 In cases where ACTS requires information that is not accessible or derivable
0057 from DD4hep data, it will look for additional parameters that mark up detector
0058 elements. One such example is the layer pattern. ACTS looks for detector
0059 elements which represent subdetectors, identified by `DetType::BARREL` and
0060 `ENDCAP`. To group sensors into layers correctly, it will search for the
0061 detector element corresponding to a layer **by name**. Which detector element
0062 names are interpreted as *layers* is steered by the `layer_pattern`
0063 parameter. It contains a regex that is evaluated against every detector element
0064 name encountered. It can be set from the XML using DD4hep's plugin mechanism
0065 and the provided `ParametersPlugin` like:
0066
0067 ```xml
0068 <detector id="ODD_PixelEndcapN_ID" name="PixelEndcapN"
0069 type="ODDPixelEndcap" readout="PixelEndcapReadout" vis="invisible">
0070 <type_flags type="DetType_TRACKER + DetType_ENDCAP"/>
0071 <!-- ... -->
0072 </detector>
0073 <!-- ... -->
0074 <plugins>
0075 <plugin name="DD4hep_ParametersPlugin">
0076 <argument value="PixelEndcapN"/>
0077 <argument value="layer_pattern: str=PixelEndcapN\d|PixelEndplate"/>
0078 </plugin>
0079 </plugins>
0080 ```
0081
0082 In this snippet, `ParametersPlugin` assigns a value of `layer_pattern:
0083 str=PixelEndcapN\d|PixelEndplate` to the detector of name `PixelEndcapN`.
0084 ACTS uses this parameter to resolve the layer detector elements.
0085
0086
0087 ## `DD4hepDetectorElement`
0088
0089 In ACTS the surfaces describing the sensitive modules of a detector are directly
0090 linked to these of the initial geometry input. In the case of DD4hep the
0091 {class}`Acts::DD4hepDetectorElement` was introduced which is the direct link of
0092 ACTS to DD4hep. In the case for tracking relevant parameters in the DD4hep
0093 geometry description are changed (e.g. alignment) it will be automatically
0094 changed in ACTS.
0095
0096 ## Build
0097
0098 The DD4hepPlugin is only build on demand. The DD4hepPlugin depends on the
0099 TGeoPlugin therefore both plugins need to be installed. During the cmake
0100 configuration the flags `ACTS_BUILD_PLUGIN_DD4HEP=on` and
0101 `ACTS_BUILD_PLUGIN_TGEO=on` need to be set. In addition, ROOT and DD4hep
0102 installations need to be available to cmake.
0103
0104 ## Prerequisites
0105
0106 To guarantee a working translation from DD4hep input to ACTS geometry the
0107 following conditions need to be met:
0108
0109 - The detector needs to have a barrel-endcap structure: Every hierarchy of
0110 subdetectors (e.g. PixelDetector, StripDetector,...) needs to be decomposed
0111 into
0112
0113 1. {barrel}
0114 2. {barrel + 2 endcaps}
0115 3. {2 endcaps} - in case there is no barrel at this stage (e.g. forward end caps)
0116
0117 These subdetectors need to be flagged using the correct `DetType`.
0118
0119 - If a hierarchy is not only a single barrel but is decomposed of a barrel
0120 and its corresponding endcaps they need to be grouped together in an
0121 assembly using the `DD4hep_SubdetectorAssembly` constructor which is
0122 provided by DD4hep. Example of usage in xml file (where Barrel0, nEndCap0
0123 and pEndCap0 are sub detectors defined in the file `PixelTracker.xml`):
0124
0125 ```xml
0126 <include ref="PixelTracker.xml"/>
0127 <detectors>
0128 <detector id="1" name="PixelTracker" type="DD4hep_SubdetectorAssembly"
0129 vis="BlueVisTrans">
0130 <shape name="PixelEnvelope" type="Tube" rmin="Env0_rmin"
0131 rmax="Env0_rmax"dz="Env0_dz" material="Air"/>
0132 <composite name="Barrel0"/>
0133 <composite name="nEndCap0"/>
0134 <composite name="pEndCap0"/>
0135 </detector>
0136 </detectors>
0137 ```
0138
0139 If a user wants to create his/her own constructor to group these
0140 volumes together the type needs to be set to "compound".
0141
0142 - Since the translation walks through the `DetElement` tree the following
0143 objects need to be declared as a DD4hep `DetElement`:
0144 - The subvolumes e.g. barrel, endcap, beampipe (they are usually built with
0145 different DD4hep constructors and are therefore DD4hep `DetElement`'s
0146 per default).
0147 - Layers when containing sensitive material and/or the layer should
0148 carry material (which will be mapped on the layer if indicated), or
0149 the layer is sensitive itself.
0150
0151 ```{note}
0152 The layer does not need to be a direct child of the volume (barrel or
0153 endcap), it an be nested in substructures
0154 ```
0155
0156 - Sensitive detector modules
0157
0158 ```{note}
0159 The sensitive detector modules need to be placed in a layer however
0160 it can be nested in substructures (can be a component of a modules)
0161 i.e. it does not need to be a direct child of the layer
0162 ```
0163
0164 - The tracking geometry needs to be built from bottom to top to ensure
0165 navigation. Therefore, the different hierarchies need to be sorted ascending.
0166 Per default the sub detectors are sorted by the id of their `DetElement`.
0167 In case another sorting needs to be applied, the users can provide their own
0168 function.
0169
0170 There are two modes building the layers around the sensitive detector modules:
0171
0172 - The `DetElement` containing the sensitive modules have a geometrical
0173 shape.
0174 The boundaries of the layers in ACTS are taken directly from the given shape.
0175
0176 - The `DetElement` containing the sensitive modules have no specific shape
0177 (assembly).
0178 The boundaries of the layers are calculated automatically by adding a
0179 tolerance to the geometric extension of the contained surfaces. The
0180 tolerances in r and z need to be set for every `DetElement` representing
0181 layer using DD4hep parameters `envelope_r_min`, `envelope_r_max`,
0182 `envelope_z_min`, `envelope_z_max`. attached to the layer detector
0183 element. (see [](acts-params))
0184
0185 ```{note}
0186 Either all or none of the `envelope_*` parameters need to be set.
0187 ```
0188
0189
0190 The volumes are automatically built around the layers. Volume boundaries for
0191 the volumes are calculated automatically by adding a tolerance to the geometric
0192 extension of the contained layers. The tolerance parameters `layerEnvelopeR`
0193 and `layerEnvelopeZ` need to be set in the
0194 {func}`Acts::convertDD4hepDetector` function.
0195
0196 Furthermore, parameters can be handed over for material mapping or the axes
0197 orientation of modules.
0198
0199 Summing up the `DetElement` tree in DD4hep should have the following
0200 structure:
0201
0202 
0203
0204 It is also possible to translate a very simple detector geometry, which just
0205 consists of cylindrical (for a barrel) or disc (for endcaps) layers which either
0206 have material, or, are declared sensitive in DD4hep themselves without
0207 containing any detector modules.
0208
0209 (acts-params)=
0210 ## Possible parameters ACTS will interpret
0211
0212 ACTS geometry translation uses parameters attached to DD4hep detector elements via the `VariantParameters` extension. You can set this extension from your factory code, or use DD4hep's plugin mechanism to set parameters on detector elements via name. Here's an excerpt from the Open Data Detector on how to use this to mark a passive structure as a *passive layer*:
0213
0214 ```xml
0215 <lccdd>
0216 <detectors>
0217 <detector id="ODD_Solenoid_ID" name="Solenoid" type="ODDCylinder" beampipe="false" vis="Aluminum">
0218 <type_flags type="DetType_TRACKER" />
0219 <boundary_material surface="inner" binning="binPhi,binZ" bins0="mat_sol_bPhi" bins1="mat_sol_bZ"/>
0220 <tubs name="Solenoid" rmin="sol_rmin" rmax="sol_rmax" dz="sol_hlength" material="Aluminum">
0221 <layer_material surface="representing" binning="binPhi,binZ" bins0="mat_sol_bPhi" bins1="mat_sol_bZ"/>
0222 </tubs>
0223 </detector>
0224 </detectors>
0225
0226 <plugins>
0227 <plugin name="DD4hep_ParametersPlugin">
0228 <argument value="Solenoid"/>
0229 <argument value="passive_layer: bool = true"/>
0230 </plugin>
0231 </plugins>
0232 </lccdd>
0233 ```
0234
0235 * Layer
0236
0237 * `envelope_{r,z}_{min,max}`: explicit envelope for a layer
0238 * `layer_material`: mark a layer as passive (use this if you want to add a passive layer that is not a beampipe)
0239 * Surface binning:
0240
0241 * `surface_binning`: set to true to indicate that explicit surface binning is set.
0242 * `surface_binning_n_{phi,r}`: surface binning for a layer
0243
0244 * Layer material:
0245
0246 * `layer_material`: set to true to indicate that the layer has layer material configuration
0247
0248 * `layer_material_representing`: set to true to indicate representing layer material
0249 * `layer_material_inner`: set to true to indicate inner layer material
0250 * `layer_material_outer`: set to true to indicate outer layer material
0251 * `layer_material_{representing,inner,outer}_bin{X,Y,Z,R,Phi,RPhi,H,Eta,Mag}` to give the number of bins in a direction
0252
0253 * Sensor
0254
0255 * `axis_definitions`: local axis definitions for a sensor. Default: `XYZ`. See {class}`Acts::DD4hepDetectorElement` for details
0256
0257 * Volume / subdetector
0258
0259 * `boundary_material`: set to true to indicate boundary material is set
0260 * `boundary_material_{negative,positive,inner,outer}` to indicate which boundary material surfaces should be set
0261 * `boundary_material_{negative,positive,inner,outer}_bin{X,Y,Z,R,Phi,RPhi,H,Eta,Mag}` to give the number of bins in a direction
0262
0263 ## Usage
0264
0265 To receive the {class}`Acts::TrackingGeometry` the global function
0266 {func}`Acts::convertDD4hepDetector` should be used, where the DD4hep world
0267 `DetElement` needs to be handed over. For a valid translation, that all
0268 prerequisites described above are met and that the right `VariantParameters`
0269 are added during the DD4hep construction.
0270
0271
0272 ## DD4hep field adapter
0273
0274 The DD4hep plugins ships with an adapter class that connects a DD4hep-defined
0275 field to the {class}`Acts::MagneticFieldProvider` interface:
0276
0277 :::{doxygenclass} Acts::DD4hepFieldAdapter
0278 :::