---
title: 'DDML: Detector Description + Machine Learning'
url: https://www.emergentmind.com/topics/lemmma-ddml
type: topic
---

# DDML: Detector Description + Machine Learning

DDML (Detector Description + Machine Learning) is a C++ library designed to enable the seamless integration of deep generative calorimeter surrogates into full-scale detector simulation and reconstruction workflows that utilize the DD4hep toolkit. Developed in response to the computational bottleneck posed by Geant4-based calorimeter shower simulations—especially in highly granular detectors—DDML allows any PyTorch or ONNX-exported model to function as a fast, modular replacement within a realistic detector chain. It replaces Geant4 showers with surrogate-generated hits directly in the DD4hep geometry, preserving compatibility with standard reconstruction (e.g., PandoraPFA) and physics-level analyses. No lemma or concept termed "LEMMA" is defined in the context of DDML [2511.17293].

## 1. Motivation and Rationale

Calorimeter simulation using Geant4 provides accurate physics modeling but incurs prohibitive computational costs for high-statistics requirements at future collider experiments. This challenge is acute in highly granular calorimeters, where a single electromagnetic or hadronic shower can generate tens or hundreds of thousands of simulated energy deposits. Deep generative models—including GANs, VAEs, normalizing flows, diffusion models, and point-cloud-based surrogates—have been proposed to accelerate calorimeter simulations. However, prior work largely restricted benchmarking to idealized, simplified detector geometries or single-particle scenarios with fixed incident conditions, without embedding the surrogates into a full workflow encompassing realistic geometry, digitization, pattern recognition, and physics evaluation. DDML addresses this gap by providing a generic interface for generative surrogates to interoperate transparently within the DD4hep/Geant4 simulation framework [2511.17293].

## 2. System Architecture and Software Interfaces

DDML is structured around five key C++ interfaces, each responsible for a functional aspect of surrogate-based simulation:

- **TriggerInterface**: Encapsulates a Geant4 fast-simulation trigger, allowing selective interception of tracks (e.g., photons or electrons above a certain energy in designated regions). Supports region and type-based vetoing for problematic geometries (module boundaries, absorber gaps).
- **ModelInterface**: Manages input preparation and output translation. Prepares input representations—comprising local entry coordinates, momentum direction, energy, and a random seed—for the neural surrogate, and post-processes network outputs (e.g., voxel grids, point clouds) to uniform local-space hit lists.
- **InferenceInterface**: Provides a backend interface to inference engines such as LibTorch or ONNX-Runtime, accepting pre-packed input tensors and returning raw model predictions. Can be stubbed with HDF5-based library lookups for rapid development cycles.
- **GeometryInterface**: Contains methods for converting global track parameters to a "shower frame" (local coordinate system aligned with the calorimeter surface and magnetic field) and for mapping generated local-space hits back into the segmented DD4hep detector geometry.
- **HitMaker**: A helper class that injects surrogate-generated hits into the Geant4 hit or step collections, emulating the native Geant4 mechanism.

The replacement loop pseudocode, executed for each intercepted track, is:

```cpp
if (Trigger.checkTrigger(track)) {
  kill Geant4 track;
  localDir = Geometry.getLocalDir(track);
  inputs   = Model.prepareInputs(track, localDir);
  rawOut   = Inference.runInference(inputs);
  localSP  = Model.convertOutput(track, localDir, rawOut);
  globalSP = Geometry.localToGlobal(track, localSP);
  for each sp in globalSP:
    HitMaker.makeHit(sp, track);
} else {
  continue full Geant4 simulation;
}
```
This loop enables DDML to insert replacement surrogates at run time with minimal overhead, leaving all downstream digitization, reconstruction, and analysis components unchanged [2511.17293].

## 3. Supported Generative Surrogate Models

DDML's flexibility allows implementation-agnostic deployment of various generative surrogates. Two state-of-the-art classes are:

- **ConvL2LFlows (Regular-Grid Normalizing-Flow Surrogate)**:
  - Operates on $90\times 90\times 30$ voxel grids ($R_{\times9}$, ninefold improved lateral granularity over the 5 mm $\times$ 5 mm baseline).
  - Employs convolutional coupling layers with Neural Spline Flows, featuring U-Net style conditioning on incident direction and layer.
  - Auto-regressive along the depth axis, with fixed sampling cost independent of incident shower energy.
  - Trained via maximum likelihood estimation on the flow Jacobian, with loss:
    $$
    L_{\rm flow} = -\sum_i \log p_X(x^{(i)}) = -\sum_i \Bigl(\log p_Z(f(x^{(i)})) + \log\bigl|\det \frac{\partial f}{\partial x}(x^{(i)})\bigr|\Bigr)
    $$

- **CaloClouds3 (Point-Cloud Diffusion Surrogate)**:
  - Generates dequantized point clouds ($R_{\times25}$; 25× finer than the base grid, with jitter for artifact suppression), retaining hits within a $500\,\text{mm}$ cube.
  - Combines a PointWiseNet (for denoising local hits) and a ShowerFlow module (enforcing global constraints).
  - Sampling employs a score-matching loss:
    $$
    L_{\rm diff} = \mathbb{E}_{x,\,t,\,\epsilon} \|\epsilon - \epsilon_\theta(x_t, t)\|^2
    $$
    with $x_t = \sqrt{\alpha_t} x + \sqrt{1-\alpha_t} \epsilon$, and inference completed in $\sim10$ DDIM-style deterministic denoising steps.
  - Sampling cost scales weakly with energy (number of hits), but realizes $>100\times$ speed-up over Geant4 on CPU [2511.17293].

## 4. Evaluation Methodology and Metrics

DDML's surrogates are evaluated through a chain that incorporates a full DD4hep detector, Geant4 or surrogate-driven calorimeter response, PandoraPFA reconstruction, and high-level physics analysis. Benchmarks are conducted in three progressive scenarios:

- **Single-Photon Showers (10–100 GeV)**: Used to evaluate basic reproduction of energy profiles, shower shapes, and energy/angular resolution.
- **Di-Photon Core Separation (5, 20, 100 GeV pairs)**: Tests model fidelity for close-by electromagnetic showers and clustering performance.
- **Full-Physics $\tau^+\tau^- \to$ hadrons $+\pi^0$ Decays**: Assesses physics-level performance for $\pi^0$ finding in realistic hadronic final states with standard event reconstruction and kinematic fitting.

Key quantitative metrics include:

- **Longitudinal/Radial Energy Profiles**: $E_\text{radial}(r) = \langle E \rangle$ in radial annuli, $E_\text{longitudinal}(\ell) = \langle E \rangle$ in layer $\ell$.
- **Energy Resolution and Linearity**: $\sigma_{90} / \mu_{90}$, $\mu_{90} / E_\text{true}$ computed from the central 90% interval.
- **Angular Resolution**: Discrepancy in $(\Delta\phi, \Delta\theta)$ between PCA-estimated and true shower axes.
- **Physics Categorization**: $\pi^0$ identification rates (nGood, nFake, nConfused, nMissed, nTotal), mass peaks ($M_{\gamma\gamma}$), and energy/angle residuals.
- **Divergences**: Jensen–Shannon (JS) divergence or L1 histogram distances quantify fit quality [2511.17293].

## 5. Quantitative Results and Comparative Analysis

Performance results for the surrogate models in DDML are summarized as follows:

| Scenario/Metric                  | Geant4 Reference      | ConvL2LFlows ($R_{\times9}$)         | CaloClouds3 ($R_{\times25}$)        |
|----------------------------------|----------------------|--------------------------------------|-------------------------------------|
| Long. profiles (single-$\gamma$) | Baseline, ideal      | ~few % agreement with Geant4         | $\lesssim 5\%$ agreement            |
| Radial profiles                  | Baseline, ideal      | $\sim$10–15% loss in edges           | $\lesssim 5\%$ agreement            |
| Energy resolution                | Optimal ($R_{\times9}$) | $\lesssim 5\%$ deviation             | $\sim 2\%$ deviation                |
| Di-photon separation             | Baseline, ideal      | $\lesssim 5\%$ deviation             | $\lesssim 5\%$ deviation            |
| $\pi^0$ finding (full-physics)   | --                   | up to $\lesssim 15\%$ deviation      | $\lesssim 3\%$ deviation            |
| Timing (100 GeV shower)          | $\sim$2 s/shower     | $\sim$1.6 s/shower (flat vs $E$)     | $\sim$15 ms/shower (slight $E$ dep.)|
| Model size (weights + activations)| --                  | 2.5 GB + 4.4 GB                      | 27 MB + 198 MB                      |

ConvL2LFlows yields moderate speed-ups (factor 1.2–2) with high geometric fidelity but greater memory usage, while CaloClouds3 achieves $\sim130\times$ speed-up with robust accuracy, especially in fine-grained reconstruction benchmarks [2511.17293].

## 6. Deployment Considerations and Extensibility

All DDML benchmarks are performed in the same Key4hep/DD4hep/Geant4/Pandora binary environment, ensuring direct comparability of computational performance. The design allows pluggable inference backends (LibTorch, ONNX-Runtime) and supports arbitrary DD4hep-described calorimeter topologies (barrel, endcap, irregular segmentation). Minimal C++ overhead ensures surrogate timing measurements are true surrogates for full Geant4 simulation. The modular interface design facilitates community-driven model innovation, systematic benchmarking across architectures, and transparent integration into large simulation campaigns [2511.17293].

## 7. Terminology Clarification

No definition, derivation, or acronym for "LEMMA" exists within this context. All formal nomenclature centers on DDML (“Detector Description + Machine Learning”) and the individually named generative surrogates. Any reference to “LEMMA” in association with DDML is unsupported in the scientific literature [2511.17293].

Source: https://www.emergentmind.com/topics/lemmma-ddml