# hep-lbdl/omnifold architecture

> Architecture diagram of the GitHub repository hep-lbdl/omnifold, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hep-lbdl/omnifold
- Repository: https://github.com/hep-lbdl/omnifold

## Overview

OmniFold is a small Python implementation and set of examples for iterative event reweighting and unfolding. The runtime entry point accepts simulated events, unknown-sample events, an iteration count, and a supplied model, then returns per-iteration weights. The main notebook documents additional background-subtraction, fake-factor, resolution, and efficiency handling. Those notebook internals and the Benchmark example were not sampled, so their detailed runtime connections are not inferred.

Main entry points: [`GaussianExample.ipynb`](https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb) (Full Gaussian example), [`omnifold.py`](https://github.com/hep-lbdl/omnifold/blob/main/omnifold.py) (Iterative reweighting), [`GaussianExample_minimal.ipynb`](https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample_minimal.ipynb) (Minimal example)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_examples["Unfolding examples"]
  node_gaussian["Full Gaussian example"]
  node_background["Background subtraction"]
  node_fakes["Fake factors"]
  node_resolution["Resolution unfolding"]
  node_efficiency["Efficiency factors"]
  node_minimal["Minimal example"]
end

subgraph group_runtime["OmniFold runtime"]
  node_algorithm["Iterative reweighting<br/>[omnifold.py]"]
end

node_analyst(("Analyst"))
node_samples["Event samples"]
node_model["Classifier model"]
node_weights["Unfolded weights"]

node_analyst -->|"runs example"| node_gaussian
node_gaussian -->|"handles background"| node_background
node_gaussian -->|"handles fakes"| node_fakes
node_gaussian -->|"unfolds resolution"| node_resolution
node_gaussian -->|"handles efficiency"| node_efficiency
node_analyst -->|"runs example"| node_minimal
node_analyst -->|"supplies inputs"| node_algorithm
node_samples -->|"provides events"| node_algorithm
node_algorithm -->|"fits classifier"| node_model
node_algorithm -->|"returns weights"| node_weights

click node_gaussian "https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb"
click node_background "https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb"
click node_fakes "https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb"
click node_resolution "https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb"
click node_efficiency "https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb"
click node_minimal "https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample_minimal.ipynb"
click node_algorithm "https://github.com/hep-lbdl/omnifold/blob/main/omnifold.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gaussian,node_background,node_fakes,node_resolution,node_efficiency,node_minimal toneBlue
class node_algorithm toneAmber
class node_analyst,node_samples,node_model,node_weights toneIndigo
```

## Components

### Unfolding examples

- [Full Gaussian example](https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb): `GaussianExample.ipynb`
- [Background subtraction](https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb): `GaussianExample.ipynb`
- [Fake factors](https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb): `GaussianExample.ipynb`
- [Resolution unfolding](https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb): `GaussianExample.ipynb`
- [Efficiency factors](https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample.ipynb): `GaussianExample.ipynb`
- [Minimal example](https://github.com/hep-lbdl/omnifold/blob/main/GaussianExample_minimal.ipynb): `GaussianExample_minimal.ipynb`

### OmniFold runtime

- [Iterative reweighting](https://github.com/hep-lbdl/omnifold/blob/main/omnifold.py): `omnifold.py`

### Other components

- **Analyst**
- **Event samples**
- **Classifier model**
- **Unfolded weights**

## Connections

- Analyst → Full Gaussian example: runs example (evidence: `README.md`)
- Full Gaussian example → Background subtraction: handles background (evidence: `README.md`)
- Full Gaussian example → Fake factors: handles fakes (evidence: `README.md`)
- Full Gaussian example → Resolution unfolding: unfolds resolution (evidence: `README.md`)
- Full Gaussian example → Efficiency factors: handles efficiency (evidence: `README.md`)
- Analyst → Minimal example: runs example (evidence: `README.md`)
- Analyst → Iterative reweighting: supplies inputs (evidence: `omnifold.py`)
- Event samples → Iterative reweighting: provides events (evidence: `omnifold.py`)
- Iterative reweighting → Classifier model: fits classifier (evidence: `omnifold.py`)
- Iterative reweighting → Unfolded weights: returns weights (evidence: `omnifold.py`)
