---
title: RECAP Pipeline for CTA
url: https://www.emergentmind.com/topics/recap-pipeline
type: topic
---

# RECAP Pipeline for CTA

The RECAP Pipeline refers to the current prototype open event-reconstruction pipeline implemented for the Cherenkov Telescope Array (CTA), the next-generation ground-based gamma-ray observatory. Designed as an open-source analysis stack and assembled in the protopipe framework, RECAP encompasses multiple tightly integrated stages for transforming raw telescope data into high-level science products. The pipeline orchestrates three major software frameworks—ctapipe, protopipe, and pyirf—executed in a linear chain of calibrated, image-based, multivariate, and instrument-response modules. Its functionality spans calibration of digitized telescope signals, image cleaning and parameterization, shower physics reconstruction (direction, energy, and gamma/hadron discrimination), and the derivation of instrument response functions (IRFs) required for sensitivity forecasting and astrophysical interpretation [2110.11097].

## 1. Pipeline Architecture and Module Interactions

RECAP adheres to a linear five-stage design, each implemented as a YAML-configured Python Tool that chains core ctapipe routines with higher-level logic in protopipe and IRF calculation in pyirf:

1. **Stage 0: Calibration & Image Extraction** (ctapipe)  
   Converts raw digitized signals into calibrated pixel charges and times, extracting images from telescope data streams.
2. **Stage 1: Image Cleaning & Pixel Selection** (ctapipe)  
   Applies multi-level charge and time thresholds to remove noise and select physically meaningful pixels.
3. **Stage 2: Image Parameterization** (ctapipe)  
   Reduces clean images to classical and auxiliary moments (Hillas parameters, skew, kurtosis, timing spread) for downstream analysis.
4. **Stage 3: Event-Level Reconstruction** (ctapipe + protopipe.mva)  
   Combines monoscopic (ML) and stereoscopic (geometric) shower reconstruction, including energy regression and particle identification.
5. **Stage 4: IRF Generation & Sensitivity Optimization** (pyirf)  
   Computes effective area, PSF, and energy dispersion histograms, optimizes gamma/hadron and angular cuts, and outputs GADF-compliant IRFs and sensitivity curves.

The overall data flow—managed via DIRAC/CTADIRAC grid orchestration—routes simulated or prototype-telescope events through ctapipe’s EventSource, calibration/image extraction, cleaning, parameterization, higher-level event reconstruction (DL1b, DL2, DL3), and IRF construction. Model training, configuration, and storage primitives are standardized throughout the toolchain.

## 2. Calibration and Image Extraction

Calibration centers on transforming digitized waveforms ($s_i[j]$) into unbiased physical signals:

- Remove pixel-wise pedestal ($P_i$), apply gain ($g_i$):  
  $\tilde{s}_i[j] = g_i\,(s_i[j] - P_i)$
- Integrate over window $W_i$ (fixed, sliding, or fit-based):  
  Pixel charge: $q_i = \sum_{j \in W_i} \tilde{s}_i[j]$  
  Mean arrival time: $t_i = \left(\sum_{j \in W_i} j \cdot \tilde{s}_i[j]\right)/q_i$

Window selection leverages pulse-shape fits and sliding maximum searchers for S/N maximization. Cleaning employs a two-threshold system: a "picture" charge ($Q_{pic}$, e.g. 5 p.e.) for core pixels and a "boundary" threshold ($Q_{bnd}$, e.g. 3 p.e.) for neighbors, plus time difference constraints. Advanced cleaning methods (e.g., wavelet or fractal) are also available.

## 3. Image Parameterization

Parameterization reduces the selected pixel field to a compact vector:

- Weighted centroid:  
  $\bar{x} = (\sum_i q_i x_i)/(\sum_i q_i), \quad \bar{y} = (\sum_i q_i y_i)/(\sum_i q_i)$
- Second central moments (Hillas):  
  Width: $w = \sqrt{\sum_i q_i (x_i - \bar{x})^2/ \sum_i q_i}$  
  Length: $\ell = \sqrt{\sum_i q_i (y_i - \bar{y})^2/ \sum_i q_i}$  
  Principal axis rotation aligns length with the shower major axis.

Higher moments and auxiliary features—such as skewness, kurtosis, and pixel-time spread—inform ML-based event discrimination and regression stages.

## 4. Event-Level Reconstruction

Two main regimes exist:

- **Monoscopic**: Uses ML regressors (e.g., random forest or AdaBoost, trained in protopipe.mva) on per-telescope Hillas plus timing features to estimate shower direction and energy.
- **Stereoscopic**: Geometric reconstruction via intersection of major axes from multiple telescopes, aggregating direction vectors $D_{k\ell}$ in a brightness-weighted scheme.

Energy estimation employs either lookup tables ($E_{est} = f(size, distance, zenith)$) or multivariate regressors. Particle ID (gamma/hadron) relies on a random-forest classifier, outputting a "gammaness" score in [0,1]. The ImPACT likelihood fit—maximizing $L(\theta) = \prod_i P(q_i \mid I_{pred,i}(\theta))$—is used for template-based event reconstruction.

## 5. Instrument Response Function (IRF) Generation

pyirf formalizes all IRFs in the generalized GADF factorization:
$$R(\hat{\alpha},\hat{\delta},\hat{E} \mid \alpha,\delta,E,t) = A_{eff}(\alpha,\delta,E,t) \cdot PSF(\hat{\alpha},\hat{\delta} | \alpha,\delta,E,t) \cdot D(\hat{E}|E,\alpha,\delta,t)$$

- **Effective area**:  
  $A_{eff}(E_{true}) = (N_{rec}(E_{true}) / N_{sim}(E_{true})) \times A_{gen}$
  Quantifies event selection relative to simulated shower generation.
- **PSF and Energy Dispersion**:  
  Binned in direction offset $\Delta\theta$, energy, and true/reconstructed bins.

pyirf outputs standard FITS IRF files and runs sensitivity optimization by adjusting "gammaness" and $\theta^2$ cuts for specified exposure durations.

## 6. Performance, Validation, and Implementation

Benchmark studies for LST-1 report:

- Angular resolution (68% containment): $\sim$0.04°–0.1° above 100 GeV, matching legacy pipelines.
- Energy resolution: $\sim$10–15% over broad energies.
- Sensitivity: 5–10× improvement over previous-generation IACT systems.

protopipe leverages numba-accelerated inner loops, multiprocessing in ctapipe’s Map, and DIRAC-based grid execution, maintaining job memory footprints at a few GB.

## 7. Future Directions

Current priorities include:

- Complete integration of real and simulated data streams via unified ctapipe I/O.
- Production release of protopipe after universal camera and mode validation.
- Incorporation of deep-learning reconstruction methods (ctlearn, gammalearn) into ctapipe.
- Time- and spatial-dependence support in pyirf’s IRF production, for variable and extended sources.
- Enhanced parallel I/O and HPC compatibility for grid-scale workflows.

These directions reflect the pipeline’s role as a flexible, extensible backbone for both operational analysis and methodological research in CTA event reconstruction [2110.11097].

Source: https://www.emergentmind.com/topics/recap-pipeline