Warning, /acts/Detray/detectors/codegen/README.md is written in an unsupported language. File is not indexed.
0001 # Detray Metadata Generator
0002
0003 `detray_metadata` generates the detector metadata headers that define a detray
0004 detector type. It is a build-time code generator, independent of the `detray`
0005 Python bindings in `Detray/python`.
0006
0007 ## Vocabulary
0008
0009 | Term | Meaning | Example |
0010 |---|---|---|
0011 | name | the key used in CMake and on the command line | `toy` |
0012 | configuration | Python module `<name>_detector` with a `configure(md)` function | `detray_metadata/configurations/toy_detector.py` |
0013 | metadata | the generated C++ type list | `detray::toy_metadata<algebra_t>` in `detray/detectors/toy_metadata.hpp` |
0014 | detector type | metadata combined with an algebra | `detray::host::detector<detray::toy_metadata<algebra_t>>`, traccc's `toy_detector` |
0015
0016 The detector metadata is a C++ `struct` used by the detray core library as a
0017 template parameter to gather the compile-time information on the capabilities
0018 of the detector modelling, with the `algebra_t` defined according to the linear
0019 algebra backend to be used, for instance the `detray::array<float>` plugin.
0020
0021 A generic metadata type (`default`) can represent all supported detectors, at
0022 the expense of increased build times and potentially slower reconstruction.
0023
0024 ## Layout
0025
0026 ```
0027 Detray/detectors/
0028 ├── include/detray/detectors/ # hand-written metadata headers only (telescope)
0029 ├── CMakeLists.txt # generates the shipped and external headers
0030 └── codegen/
0031 ├── generate_metadata.py # CLI used by the codegen manifest
0032 └── detray_metadata/
0033 ├── impl/ # metadata model and header rendering
0034 ├── options/ # command line options
0035 ├── utils/ # reusable tracker/material defaults
0036 └── configurations/ # <name>_detector.py, one per shipped detector
0037 ```
0038
0039 ## Building
0040
0041 The shipped configurations (`default`, `itk`, `odd`, `toy`, `wire_chamber`) are
0042 always generated through the ACTS codegen manifest, or taken from prebuilt
0043 headers. Generated headers are never committed.
0044
0045 To generate a header manually:
0046
0047 ```shell
0048 PYTHONPATH=Detray/detectors/codegen \
0049 python3 Detray/detectors/codegen/generate_metadata.py odd_metadata.hpp --detector odd
0050 ```
0051
0052 ### Adding a shipped detector
0053
0054 Add `configurations/<name>_detector.py` with a `configure(md)` function, a
0055 manifest unit `Detray/detectors/detray/detectors/<name>_metadata.hpp` with
0056 `"arguments": ["--detector", "<name>"]`, and `<name>` to the list in
0057 `Detray/detectors/CMakeLists.txt`.
0058
0059 ### External configurations
0060
0061 A configuration outside this repository follows the same convention:
0062
0063 ```python
0064 # /path/to/custom_detector.py
0065 from detray_metadata import add_silicon_tracker_defaults
0066
0067
0068 def configure(md):
0069 add_silicon_tracker_defaults(
0070 md, use_homogeneous_mat=True, use_mat_maps=True, add_trapezoid=True
0071 )
0072 ```
0073
0074 Select it with
0075 `-DDETRAY_GENERATE_METADATA='/path/to/custom_detector.py:configure'`
0076 (semicolon-separated), or pass `--detector /path/to/custom_detector.py:configure`
0077 to `generate_metadata.py`. A trailing `_detector` is dropped from the file stem
0078 to form the name, so this produces `detray/detectors/custom_metadata.hpp` with
0079 `detray::custom_metadata`. The name must not reuse a shipped one. CMake tracks
0080 changes to the configuration file.
0081
0082 External configurations use the common generator runtime and prebuilt lookup,
0083 but are not part of release pregeneration. They generate locally unless a header
0084 is supplied at
0085 `<prebuilt-dir>/Detray/detectors/detray/detectors/custom_metadata.hpp`; strict
0086 prebuilt mode rejects a missing header.
0087
0088 Alternatively, `detray_metadata` can be imported from a script of your own that
0089 builds a `metadata` object and calls `metadata_generator` directly.
0090
0091 ### Metadata Configuration Manual
0092
0093 Generate a metadata representation and dump the header file:
0094
0095 ```python
0096 from detray_metadata import metadata, metadata_generator
0097
0098 md = metadata("detector_name")
0099
0100 [...]
0101
0102 metadata_generator(md)
0103 ```
0104
0105 Adding surface shapes for passive or sensitive detector elements or portals between detector sub-volumes: