|
| 1 | +# Quickstart |
| 2 | + |
| 3 | +The smallest end-to-end example: build a wire detector, generate a synthetic |
| 4 | +event, run the simulation, and plot the readout. No external data needed. |
| 5 | + |
| 6 | +For the runnable version, see |
| 7 | +[`notebooks/getting_started/00_quickstart.ipynb`](https://github.com/DeepLearnPhysics/JAXTPC/blob/main/notebooks/getting_started/00_quickstart.ipynb). |
| 8 | + |
| 9 | +```python |
| 10 | +import jax, numpy as np, matplotlib.pyplot as plt |
| 11 | +from tools.simulation import DetectorSimulator |
| 12 | +from tools.geometry import generate_detector |
| 13 | +from tools.loader import build_deposit_data |
| 14 | +from tools.output import to_sparse |
| 15 | +from tools.visualization import visualize_wire_signals |
| 16 | + |
| 17 | +# 1. Build a dual-TPC wire detector |
| 18 | +detector = generate_detector("config/cubic_wireplane_config.yaml") |
| 19 | +sim = DetectorSimulator(detector, include_track_hits=True, include_digitize=True, |
| 20 | + total_pad=50_000, response_chunk_size=10_000) |
| 21 | +cfg = sim.config |
| 22 | + |
| 23 | +# 2. Generate a synthetic event (a few straight MIP-like tracks) |
| 24 | +def make_synthetic_event(seed=0, n_tracks=6, step_cm=0.4): |
| 25 | + rng = np.random.RandomState(seed) |
| 26 | + P, DE, DX, TID = [], [], [], [] |
| 27 | + for t in range(n_tracks): |
| 28 | + start = rng.uniform(-180, 180, 3); d = rng.normal(size=3); d /= np.linalg.norm(d) |
| 29 | + n = int(rng.uniform(80, 250) / step_cm); s = np.arange(n) * step_cm |
| 30 | + pts = np.clip(start[None, :] + s[:, None] * d[None, :], -215.9, 215.9) |
| 31 | + P.append(pts); DE.append(np.full(n, rng.uniform(1.8, 2.6) * step_cm, np.float32)) |
| 32 | + DX.append(np.full(n, step_cm, np.float32)); TID.append(np.full(n, t, np.int32)) |
| 33 | + return (np.concatenate(P) * 10).astype(np.float32), np.concatenate(DE), np.concatenate(DX), np.concatenate(TID) |
| 34 | + |
| 35 | +pos_mm, de, dx, track_ids = make_synthetic_event() |
| 36 | +deposits = build_deposit_data(pos_mm, de, dx, cfg, track_ids=track_ids) |
| 37 | + |
| 38 | +# 3. Run |
| 39 | +sim.warm_up() |
| 40 | +signals, track_hits_raw, deposits = sim.process_event(deposits, key=jax.random.PRNGKey(42)) |
| 41 | + |
| 42 | +# 4. Sparse output + plot |
| 43 | +sparse = to_sparse(signals, cfg, threshold_adc=1200 / cfg.electrons_per_adc) |
| 44 | +visualize_wire_signals(sparse, cfg, threshold_enc=1200, gamma=0.2, sparse=True) |
| 45 | +plt.show() |
| 46 | +``` |
| 47 | + |
| 48 | +To simulate **real data**, replace step 2 with: |
| 49 | + |
| 50 | +```python |
| 51 | +from tools.loader import load_event |
| 52 | +deposits = load_event("events.h5", cfg, event_idx=0) |
| 53 | +``` |
| 54 | + |
| 55 | +## Next steps |
| 56 | + |
| 57 | +- [`notebooks/getting_started/wire_simulation.ipynb`](https://github.com/DeepLearnPhysics/JAXTPC/blob/main/notebooks/getting_started/wire_simulation.ipynb) — full walkthrough with truth/track labels |
| 58 | +- [`notebooks/readout/pixel_simulation.ipynb`](https://github.com/DeepLearnPhysics/JAXTPC/blob/main/notebooks/readout/pixel_simulation.ipynb) — pixel readout |
| 59 | +- [Units (ENC vs ADC)](physics/units.md) and [Coordinates](concepts/coordinates.md) — the two conventions to know |
0 commit comments