Back to home page

EIC code displayed by LXR

 
 

    


Warning, /acts/docs/pages/material_map_json_schema.md is written in an unsupported language. File is not indexed.

0001 @page material_map_json_schema Material map schema
0002 
0003 Version 1 stores **surface material**. @ref Acts::TrackingGeometryMaterialJsonConverter
0004 reads and writes JSON or CBOR, optionally compressed with zstd. `toJson`/`fromJson`
0005 convert documents; `toFile`/`fromFile` handle files. @ref Acts::TrackingGeometryMaterialJsonConverter::Options "Options" controls indentation
0006 compression level and optional material quantization. Applying material to geometry is a separate operation:
0007 
0008 @snippet{trimleft} examples/material_map_json.cpp Read and write material map
0009 
0010 Python exposes the converter as `acts.json.TrackingGeometryMaterialJsonConverter`.
0011 Volume material remains available through the legacy format; version 1 rejects it.
0012 
0013 The schema is in `Plugins/Json/schema/material-map-v1.schema.json` and installs
0014 under `share/Acts/schema`. It defines fields, variants and numeric bounds.
0015 Examples in `docs/examples/material-map-v1/` cover homogeneous material
0016 (`minimal.json`), mapped surfaces (`surfaces.json`) and mapping templates
0017 (`templates.json`). Their relative `$schema` references support editor validation.
0018 
0019 @ref Acts::TrackingGeometryMaterial::fromGeometry extracts assignments without
0020 modifying the geometry or resolving deferred binning. `includeNonMaterial=True`
0021 adds deferred one-bin proto grids for bare surfaces. Pass the result directly to
0022 @ref Acts::TrackingGeometryMaterialJsonConverter::toFile; volume assignments are
0023 preserved during extraction but rejected by the version 1 converter.
0024 After running the Python mapping example, `mapping.material` holds the finalized
0025 assignments for serialization in the same way.
0026 
0027 `acts.IMaterialDecorator.fromFile` supports both formats. The new converter rejects
0028 legacy input with an error pointing to `ActsMaterialMapMigrate`.
0029 
0030 The JSON plugin also installs `ActsMaterialMapMigrate` in `bin` to migrate
0031 files written by the legacy material converter or ROOT material writer:
0032 
0033 ```sh
0034 ActsMaterialMapMigrate old-material.json material.json
0035 ActsMaterialMapMigrate material.root material.json.zst
0036 ActsMaterialMapMigrate old-material.json.zst material.cbor.zst \
0037     --material-fraction-bits 16 --compression-level 19
0038 ```
0039 
0040 ROOT inputs are selected by the `.root` extension and require a build with
0041 `ACTS_BUILD_PLUGIN_ROOT=ON`. They use the default ROOT material tree/folder names.
0042 ROOT migration preserves the assignments reconstructed by
0043 @ref ActsPlugins::RootMaterialDecorator; stable keys, mapping settings and
0044 independent electron-density/excitation-energy overrides are not stored by that
0045 format. Files with volume material are rejected, as are ROOT files containing
0046 no recognized material maps.
0047 
0048 For JSON/CBOR, input encoding is detected from its contents. The output extension selects
0049 JSON or CBOR, with optional zstd compression. Defaults preserve full float32
0050 precision, use four-space indentation and zstd level 9. `--indentation` changes
0051 text indentation; `--help` lists all options. Volume material causes migration
0052 to fail because version 1 only supports surfaces. The tool preserves material
0053 assignments and stable keys supported by the legacy reader; unrelated geometry
0054 annotations in decorated legacy files are not part of the new material format.
0055 Migration uses the legacy reader's semantics, including its default split factors
0056 (the legacy format does not store them) and normalization of single-bin axes;
0057 it cannot recover settings already lost by the legacy format.
0058 
0059 @include examples/material-map-v1/minimal.json
0060 
0061 ## Document and assignments
0062 
0063 `header` contains `format: "acts-material-map"`, `version: 1`, and an optional
0064 human-readable `description`. Unknown versions are rejected. Read or change the
0065 description through @ref Acts::TrackingGeometryMaterial::description "description()" and @ref Acts::TrackingGeometryMaterial::setDescription "setDescription()".
0066 The optional root `$schema` identifies the schema; it is not fetched by the reader.
0067 
0068 `surfaces` contains material assignments; `slab_stores` holds shared grid data.
0069 An empty assignment list is valid.
0070 
0071 | Target kind | Matching |
0072 | --- | --- |
0073 | `geometry-id` | Exact `geometry_id`, without hierarchy wildcards |
0074 | `stable-key` | Exact `key`; `recorded_geometry_id` is diagnostic only |
0075 
0076 Geometry IDs use integer components `volume`, `portal`, `layer`, `passive`,
0077 `sensitive` and `extra`. Omitted components mean **zero, never wildcards**.
0078 `portal` names the boundary bit field; `passive` names the shared approach/passive
0079 bit field. Packed IDs are not supported.
0080 Stable keys are nonempty and case-sensitive. Duplicate identities are errors;
0081 a proto payload's `material_key`, when present on a keyed assignment, must match.
0082 
0083 Absent assignments leave geometry unchanged. Null payloads are allowed only for
0084 unkeyed assignments and are a no-op when applied. Vacuum is an explicit material,
0085 not an absent assignment. Proto materials describe mapping intent; merged markers
0086 record lost material and cannot be applied as physical material.
0087 
0088 ## Values and units
0089 
0090 The required `header.units` declares base units by name. Writers use:
0091 
0092 ```json
0093 "units": {"length": "mm", "angle": "rad", "energy": "GeV", "material_amount": "mol"}
0094 ```
0095 
0096 | Quantity | Accepted units |
0097 | --- | --- |
0098 | `length` | `nm`, `um`, `mm`, `cm`, `m` |
0099 | `angle` | `rad`, `mrad`, `deg` |
0100 | `energy` | `eV`, `keV`, `MeV`, `GeV`, `TeV` |
0101 | `material_amount` | `mol`, `mmol`, `kmol` |
0102 
0103 Readers convert to Acts units and reject unknown or dimensionally wrong names.
0104 Both molar densities use **material_amount / length³**; there is no compound-unit
0105 parser. Changing a length unit therefore also requires rescaling density values.
0106 Lengths cover slab thickness, material lengths, translations and length-valued
0107 axes. `phi`/`theta` use the angle unit; `eta` and normalized deferred edges are
0108 dimensionless. Axis ranges without a direction use the length unit; `rphi` uses
0109 length with azimuth in radians. Relative atomic mass and atomic number are
0110 dimensionless.
0111 Material fields preserve radiation and interaction lengths, relative atomic mass,
0112 atomic number, molar density, molar electron density and mean excitation energy.
0113 The last two are stored independently rather than reconstructed from the others.
0114 
0115 Vacuum is `{"kind":"vacuum"}`. The string `"infinity"` is allowed for radiation
0116 and interaction lengths; numeric NaN and infinities are outside the format.
0117 Slabs retain thickness, including for vacuum. Surface settings preserve mapping
0118 type (`default`, `pre`, `post`, `sensor`) and split factor in [0,1]. Proto materials
0119 require split factor 1.
0120 
0121 ## Optional quantization
0122 
0123 @ref Acts::TrackingGeometryMaterialJsonConverter::Options::materialFractionBits
0124 controls the retained float32 fraction bits (0–23); the default 23 leaves values
0125 unchanged. Lower values improve compression by rounding built-in material
0126 properties and slab thickness to fewer bits. Rounding uses nearest, ties to even,
0127 with relative error at most `2^(-bits-1)` for normal values. Zeros, subnormals,
0128 infinities and values that would overflow are preserved.
0129 
0130 Geometry, axes, settings and custom payloads are unchanged. Quantization applies
0131 to canonical output units and does not change the schema or reader. It is
0132 available through `toJson` and `toFile`, including the Python options.
0133 
0134 ## Axes and storage
0135 
0136 @ref Acts::BinUtility "BinUtility" is being phased out. Its binned/proto and
0137 subdivided-axis encodings are retained for compatibility. Prefer
0138 @ref Acts::GridSurfaceMaterial and @ref Acts::ProtoGridSurfaceMaterial for new code.
0139 
0140 Arrays are dense, flat and zero-based, with **axis 0 varying fastest**:
0141 `offset = i0 + size0 * i1`. This differs from native @ref Acts::MultiAxis "MultiAxis" storage order;
0142 the converter handles the permutation.
0143 
0144 - Binned surfaces store regular cells only, with one or two axes.
0145 - Grid surfaces have two resolved axes and include underflow and overflow cells
0146   on both axes, including bound/closed axes. Each extent is `bins + 2`.
0147 - `open` uses guard cells, `bound` clamps, and `closed` wraps. Intervals include
0148   the lower edge and exclude the upper edge. @ref Acts::BinUtility "BinUtility" `open` maps to `bound`.
0149 - Equidistant axes have a range and bin count; variable axes have increasing
0150   edges. Grid lookup uses surface-local coordinates in axis order.
0151 - Binned/proto material may carry a rigid local-to-global transform: a row-major
0152   3×3 rotation and a translation vector. An omitted transform is identity.
0153 - Subdivided @ref Acts::BinUtility "BinUtility" axes preserve their base and subdivision: `replace`
0154   refines one matching interval; `repeat` tiles the subdivision in every base bin.
0155   Legacy `theta`/`mag` @ref Acts::BinUtility "BinUtility" directions and custom coordinate callbacks
0156   are not supported.
0157 
0158 Proto-grid axes may defer ranges, directions and boundary behavior to geometry.
0159 Deferred-variable edges run from 0 to 1 and scale to the resolved range.
0160 Explicit properties must agree with geometry. Resolved material cannot contain
0161 unresolved axes. Proto surface binning may have zero axes for homogeneous mapping.
0162 
0163 | Grid storage | Slab data |
0164 | --- | --- |
0165 | `direct` | Slab values in each cell |
0166 | `indexed` | Cell indices into a local `slabs` list |
0167 | `globally-indexed` | Cell indices into a named entry in `slab_stores` |
0168 
0169 Indices must be in range. References to the same store retain shared allocation;
0170 separate stores remain separate even if their values are equal.
0171 
0172 ## Validation and compatibility
0173 
0174 Run `python CI/check_material_schema.py` with `jsonschema>=4.18` to validate the
0175 schema and examples, or use the pre-commit hook. Schema tests run with
0176 `python -m pytest CI/check_material_schema.py`.
0177 
0178 The schema checks structure and physical-value bounds. The C++ reader checks
0179 format/version, sizes, identities and references needed to construct material;
0180 it does not perform full schema validation. Geometry application checks matching
0181 and resolves deferred axes. Schema validity alone does not guarantee that a map
0182 can be applied to a particular geometry.
0183 
0184 The schema rejects unknown fields. The reader ignores unused fields except
0185 `volumes`, which is rejected. @ref Acts::TrackingGeometryMaterialJsonConverter::Config "Config" supports custom material dispatchers;
0186 custom kinds also need an extended schema for offline validation. Encoder and
0187 decoder contexts expose unit factors for custom payloads; encoding divides by
0188 the factor and decoding multiplies by it.
0189 
0190 Legacy conversion follows decode → @ref Acts::TrackingGeometryMaterial "TrackingGeometryMaterial" → new encode.
0191 It cannot recover information already lost by the legacy reader or format,
0192 such as omitted settings, guard cells, store sharing or independent material
0193 properties. Existing legacy converters retain their behavior.