Metadata-Version: 2.4
Name: vikshep-ingest
Version: 0.4.0
Summary: Vikshep Geant4 Direct Interface: Geant4 CSV to deterministic scattering features, calibration and DisCo-decorrelated tagging
Author: Samvardhan Singh
License-Expression: AGPL-3.0-or-later
Project-URL: Homepage, https://vikshep.vercel.app
Project-URL: Repository, https://github.com/samvardhan03/Vikshep
Project-URL: Open core, https://github.com/samvardhan03/vikshep-compute
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Intended Audience :: Science/Research
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: uproot>=5
Requires-Dist: awkward>=2
Requires-Dist: numpy>=1.26
Requires-Dist: scipy>=1.11
Requires-Dist: pandas>=2
Requires-Dist: scikit-learn>=1.3
Requires-Dist: fastapi
Requires-Dist: uvicorn
Requires-Dist: h5py>=3
Requires-Dist: vikshep-compute==0.1.0; (sys_platform == "linux" and (platform_machine == "x86_64" or platform_machine == "aarch64")) or sys_platform == "darwin" or (sys_platform == "win32" and platform_machine == "AMD64")
Provides-Extra: scattering
Requires-Dist: vikshep-compute==0.1.0; extra == "scattering"
Provides-Extra: sim
Requires-Dist: pyarrow>=14; extra == "sim"

# vikshep-ingest

The Geant4 Direct Interface of [Vikshep](https://vikshep.vercel.app): from
Geant4 output to physics answer. It reads the per-hit CSV you already export
from Geant4, computes the per-event, per-layer quantities usually derived by
hand in pandas, rasterizes each event onto a detector-native (phi, theta)
grid, and runs two analysis recipes on deterministic wavelet-scattering
features: detector calibration, and particle tagging decorrelated from a
protected variable with the exact weighted distance correlation (DisCo).

```bash
pip install vikshep-ingest
```

On Linux (x86_64, aarch64), macOS and Windows (x86_64) this also installs the
open deterministic core,
[vikshep-compute](https://github.com/samvardhan03/vikshep-compute), as a
prebuilt wheel. On other platforms the recipes fall back to per-event
aggregates and say so; `pip install "vikshep-ingest[scattering]"` requests
the core explicitly.

## Quickstart

With the synthetic sample from the repository (`examples/g4_quickstart/sample.csv`: 1000
events with the truth columns `is_signal`, `true_energy` and `weight`) or your own export in
the same shape:

```bash
# 1. CSV to rasterized grids (named by 28-character content IDs) and a manifest
vikshep-ingest g4 sample.csv --schema komal_v1 --out run/

# 2. Calibration: reconstruct the incident energy from the detector images
vikshep-recipe calibrate --features run/manifest.json --target true_energy

# 3. Tagging, decorrelated from energy with weighted DisCo
vikshep-recipe tag --features run/manifest.json \
  --label is_signal --protect true_energy --weights weight --lambda 1.0
```

Every run writes a report and a `provenance.json` (VDS-1 schema) next to its
outputs, so a result can be reproduced bit for bit.

## Input profiles

| Profile | Rows |
|---|---|
| `komal_v1` | per-hit `event_id, layer (1-3), phi, theta, momentum[, energy]` |
| generic | any Geant4 ntuple export, mapped with `--column-map map.json` |

Malformed rows are counted and reported, never dropped silently. Extra columns with one
numeric value per event (truth labels, the incident energy, MC weights) are kept as event
columns: usable as `--label`, `--protect`, `--weights` or `--target`, never as features.

## Simulated runs

Output folders of [vikshep-sim](https://github.com/elli0t-yash/vikshep-sim), the open Geant4
runner, are read directly (each run's OID is checked against its `run_summary.json`):

```bash
pip install "vikshep-ingest[sim]"
vikshep-ingest sim runs/electron_5 runs/pion_5 --signal runs/electron_5 --out ana
vikshep-recipe tag --features ana/manifest.json --label is_signal --protect primary_energy_GeV
```

## Licence

AGPL-3.0-or-later, or a commercial licence from the copyright holder:
https://github.com/samvardhan03/Vikshep/blob/main/LICENSING.md
