Getting started

phepex is a C++17 library with optional Python bindings. The two can be used independently. The build/usage snippets below are the same ones shown in the project README, kept in sync from a single source.

C++ library

All kernels are free functions in namespace phepex, operating on caller-owned buffers (raw pointers + sizes). See include/phepex/*.hpp; umbrella header phepex/phepex.hpp.

#include <phepex/phepex.hpp>
// phepex::deconvolve_upsample(wf, n_ch, n_pix, n_samples, upsampling, pole_zero, base, scale, out);
// phepex::pos_soft_clip / neighbor_peak_indices / extract_around_peak / adaptive_centroid / generate_waveforms

Build & install:

cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/your/prefix
cmake --build build -j
cmake --install build      # headers, libphepex.{so,a}, CMake package, pkg-config

Consume it — CMake (find_package):

find_package(phepex REQUIRED)
target_link_libraries(app PRIVATE phepex::phepex)        # or phepex::phepex_static

or pkg-config (Makefile-based projects):

g++ -std=c++17 app.cpp $(pkg-config --cflags --libs phepex)

A runnable example is in examples/example.cpp (build with -DPHEPEX_BUILD_EXAMPLES=ON).

See the C++ API reference for the full signatures.

Python bindings

pip install .            # builds the phepex wheel (scikit-build-core + nanobind)
import phepex
# phepex.deconvolve, phepex.pos_soft_clip, phepex.neighbor_peak_indices,
# phepex.extract_around_peak, phepex.adaptive_centroid, phepex.generate_waveforms

import phepex pulls only numpy + the compiled extension. The ctapipe-integrated phepex.extractor.FastFlashCamExtractor (a drop-in accelerating ctapipe’s FlashCamExtractor) is a separate submodule imported on demand.

Install the ctapipe stack for the extractor with the bench extra (pip install .[bench]). See the Python API reference.

Benchmark

benchmarks/benchmark_fast_extractor.py compares stock ctapipe FlashCamExtractor against phepex.extractor.FastFlashCamExtractor on synthetic gamma-like FlashCam-MST events (needs the bench extra: pip install .[bench]):

python3 benchmarks/benchmark_fast_extractor.py --events 5000

Typical result: ~5× faster end-to-end (leading-edge timing on), with bit-exact / ~1e-7 agreement on signal pixels. Tests: python3 -m pytest tests/ -q.