Back to home page

EIC code displayed by LXR

 
 

    


Warning, /acts/Detray/README.md is written in an unsupported language. File is not indexed.

0001 # detray
0002 
0003 Detray is a modern, C++20 header-only library providing a GPU-friendly tracking detector description using different linear algebra libraries. It follows the navigation and propagation concept of ACTS, but implementing a geometry using a flat memory layout and no abstract interfaces (virtual functions). A detray detector can therefore be constructed on the host and copied to an accelerator device in a straight-forward way.
0004 
0005 With the geometry description comes a fully featured, GPU-ready track state propagation implementation in inhomogeneous magnetic fields (vector field description using [covfie](https://github.com/acts-project/covfie)), with track parameter covariance transport including material interactions.
0006 
0007 ## Requirements and Dependencies
0008 #### OS & Compilers:
0009 
0010 - The C++ compiler must support C++20
0011 - The CUDA Toolkit version must be greater than major version 11
0012 
0013 #### Dependencies:
0014 - CMake (version >= 3.21)
0015 
0016 
0017 ## Getting started
0018 
0019 The repository should build "out of the box", with standard
0020 CMake build procedures.
0021 
0022 ```shell
0023 git clone https://github.com/acts-project/acts.git
0024 cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -S Acts/Detray -B detray-build
0025 cmake --build detray-build
0026 ```
0027 
0028 For unit and integration tests using the *Open Data Detector* (ODD) solenoid field, a magnetic field map file in covfie format needs to be downloaded and the corresponding environment variable should be set to:
0029 ```shell
0030 cd Detray/data
0031 bash detray_data_get_files.sh
0032 export DETRAY_BFIELD_FILE="${PWD}/odd-bfield_v0_9_0.cvf"
0033 ```
0034 
0035 #### Build options
0036 
0037 A number of cmake preset configurations are provided and can be listed by:
0038 ```shell
0039 cmake -S Acts/Detray --list-presets
0040 ```
0041 For a developer build, the `detray-dev-fp32` and `detray-dev-fp64` configurations are available (`fp`: floating point precision):
0042 ```shell
0043 cmake -S Acts/Detray -B detray-build --preset detray-dev-fp32
0044 ```
0045 The developer presets will build the components of detray that are most commonly used. The `prefetch` presets on the other hand will configure all possible dependencies, but not automatically trigger the build of the corresponding components. For example, in order to trigger the build of the unit tests with the `prefetch` preset, the corresponding option needs to be specified:
0046 ```shell
0047 cmake -S Acts/Detray -B detray-build --preset detray-prefetch-fp32 \
0048 -DDETRAY_ARRAY_PLUGIN=ON -DDETRAY_BUILD_UNITTESTS=ON
0049 ```
0050 A full build, containing all components (e.g. tests and benchmarks), can be configured using the `detray-full-fp32` and `detray-full-fp64` presets.
0051 
0052 The following cmake options are available and can also be specified explicitly for any preset:
0053 
0054 | Option | Description | Default |
0055 | --- | --- | --- |
0056 | DETRAY_SET_LOGGING  | Set log level (NONE, WARN, INFO, VERBOSE, DEBUG) | INFO |
0057 | DETRAY_BUILD_CUDA  | Build the CUDA sources included in detray | ON (if available) |
0058 | DETRAY_BUILD_SYCL  | Build the SYCL sources included in detray | OFF |
0059 | DETRAY_BUILD_TEST_UTILS  | Build the detray test utilities library (contains e.g. test detectors) | OFF |
0060 | DETRAY_BUILD_UNITTESTS  | Build the detray unit tests | OFF |
0061 | DETRAY_BUILD_INTEGRATIONTESTS  | Build the detray integration tests | OFF |
0062 | DETRAY_BUILD_ALL_TESTS  | Build the detray unit and integration tests | OFF |
0063 | DETRAY_BUILD_BENCHMARKS  | Build the detray benchmarks | OFF |
0064 | DETRAY_BUILD_CLI_TOOLS  | Build the detray command line tools | OFF |
0065 | DETRAY_BUILD_TUTORIALS  | Build the examples of detray | OFF |
0066 | DETRAY_CUSTOM_SCALARTYPE | Floating point precision | float |
0067 | DETRAY_GENERATE_METADATA | List of metadata generator scripts (separated by semicolon) | empty |
0068 | DETRAY_EIGEN_PLUGIN | Build Eigen math plugin | OFF |
0069 | DETRAY_FASTOR_PLUGIN | Build Fastor math plugin | OFF |
0070 | DETRAY_SMATRIX_PLUGIN | Build ROOT/SMatrix math plugin | OFF |
0071 | DETRAY_VC_AOS_PLUGIN | Build Vc based AoS math plugin | OFF |
0072 | DETRAY_VC_SOA_PLUGIN | Build Vc based SoA math plugin (currently only supports the ray-surface intersectors) | OFF |
0073 | DETRAY_SVG_DISPLAY | Build ActSVG display module | OFF |
0074 
0075 ## Tutorials
0076 
0077 In the `tutorials` folder of the repository, there are a number of standalone executables that showcase different tasks:
0078 - Building a detector (either a predefined one or designing a detector from scratch)
0079 - Detector file IO
0080 - Additional debugging options, like performing a ray scan or obtaining
0081 extra navigation tracing information
0082 - Moving a detector to device
0083 - Host and device track propagation
0084 
0085 In order to define a custom detector geometry type (called a detector 'metadata'), please follow the instructions in `Acts/Detray/detectors/README.md`.
0086 
0087 Otherwise, the default detector metadata (`#include Acts/Detray/detectors/default_metadata.hpp`) can be used in most cases to define the detector type, however, incurring increased build times and likely also increased runtime of client algorithms.
0088 
0089 ## Detector Validation
0090 
0091 Given a detray detector (and optionally also a grid and a material) json file, a number of validation test can be run from the command-line. For this, the library has to be built with the `-DDETRAY_BUILD_CLI_TOOLS=ON` option enabled. An example detector file can then be obtained using e.g.
0092 ```shell
0093 detray-build/bin/detray_generate_toy_detector --write_material --write_grids
0094 ```
0095 All of the validation tools presented in the following can also be run as part of a corresponding [python script](https://github.com/acts-project/Acts/Detray/tests/tools/python) which takes the same arguments and will automatically create plots from the collected data. However, this requires Python 3, pandas, SciPy and NumPy, as well as Matplotlib to be available.
0096 
0097 The detector geometry can be visualized in SVG format with the following command:
0098 ```shell
0099 detray-build/bin/detray_detector_display \
0100    --geometry_file  ./toy_detector/toy_detector_geometry.json
0101 ```
0102 The tool can also display single volumes or surfaces, as well as the navigation grids and material maps (the corresponding json files need to loaded in this case). For an overview of all available options for the command-line tools add `--help`.
0103 
0104 ### Navigation Validation
0105 
0106 In order to validate that the navigation works correctly in a given detector geometry, run the detector validation tool. It will first perform a consistency check on the detector, followed by a "ray scan" of the detector. The scan result will be compared to a full straight-line navigation run for every ray. After that, the navigation in a constant magnetic field of 2T is being tested in a similar fashion, using parameterized helix trajectories and a Newton-Raphson/Bisection algorithm to generate the truth intersections. For example:
0107 ```shell
0108 detray-build/bin/detray_navigation_validation \
0109     --geometry_file ./toy_detector/toy_detector_geometry.json \
0110     --grid_file ./toy_detector/toy_detector_surface_grids.json \
0111     --search_window 3 3 --n_tracks 100 --pT_range 0.5 100
0112 ```
0113 In case of failures, this command will give a detailed debug output in the form of a log file, as well as an SVG representation of the failed tracks. The grid file is optional, but will trigger the use of spatial grids as acceleration structures during the navigation run.
0114 
0115 Note: The `search_window` option defines the size of lookup area of the grid acceleration structure and is therefore detector dependent! Use `--search_window 3 3` (or larger) for the *toy detector* and *wire chamber* example detectors and `--search_window 0 0` otherwise.
0116 
0117 ### Material Validation
0118 
0119 This tool checks whether the navigator picks up the material correctly by comparing the material found during a ray scan with the material collected during navigation by a specialized actor:
0120 ```shell
0121 detray-build/bin/detray_material_validation \
0122     --geometry_file ./toy_detector/toy_detector_geometry.json \
0123     --material_file ./toy_detector/toy_detector_homogeneous_material.json \
0124     --phi_steps 100 --eta_steps 100 --eta_range -4 4
0125 ```
0126 Note: The correct material file must be loaded in addition to the geometry file!
0127 
0128 
0129 ## Benchmarks
0130 
0131 A number of benchmarks exist, which are based on the google benchmark library, and can be run from command-line. For this, the `-DDETRAY_BUILD_BENCHMARKS=ON` and `-DDETRAY_BUILD_CLI_TOOLS=ON` flags need to be specified. Then pass the detray detector file(s) and additional options to the benchmark tools for the different hardware backends:
0132 ```shell
0133 detray-build/bin/detray_propagation_benchmark_<backend>_<algebra> \
0134     --geometry_file ./toy_detector/toy_detector_geometry.json \
0135     --grid_file ./toy_detector/toy_detector_surface_grids.json \
0136     --material_file ./toy_detector/toy_detector_homogeneous_material.json \
0137     --sort_tracks --randomize_charge --eta_range -3 3 --pT_range 0.5 100 \
0138     --search_window 3 3 --covariance_transport --bknd_name [HW_BACKEND_NAME]
0139 ```
0140 For every algebra-plugin that was built, a corresponding benchmark executable will be present. The CPU-backend benchmark is built by default and the CUDA-backend benchmark will be available if detray was built with CUDA enabled (`-DDETRAY_BUILD_CUDA=ON`). This executable can additionally be configured with any arguments targeted at [google benchmark](https://github.com/google/benchmark/blob/main/docs/user_guide.md).
0141 
0142 If the data is dumped into json files using the options `--benchmark_repetitions=N` (N standing for the number of repetitions), `--benchmark_display_aggregates_only=true`, as well as `--benchmark_out_format=json` and `--benchmark_out=<some_file_name>.json`, it can afterwards be plotted with e.g.:
0143 ```shell
0144 python3 detray/tests/tools/python/propagation_benchmarks.py \
0145     --geometry_file ./toy_detector/toy_detector_geometry.json \
0146     --data_files [FILES]...
0147 ```