CTLearn: Deep Learning Reconstruction for IACTs
- CTLearn is an open-source deep learning framework designed for event reconstruction in imaging atmospheric Cherenkov telescopes, integrating TensorFlow with domain-specific data handling.
- It employs tailored neural architectures, including Thin-ResNet variants and dynamic LSTM networks, optimized through the preprocessing of calibrated and cleaned camera data.
- CTLearn has been validated across CTA, MAGIC, and LST-1 experiments, achieving competitive gamma/hadron classification, energy regression, and direction reconstruction with standard IACT performance metrics.
CTLearn is an open-source framework for deep-learning–based event reconstruction in imaging atmospheric Cherenkov telescopes (IACTs). In the IACT literature, it denotes a Python package built around TensorFlow for loading and manipulating telescope data, training neural models on pixel-wise camera inputs, and reconstructing the primary particle’s type, energy, and arrival direction. Across its published uses, CTLearn functions as a domain-specific reconstruction backend rather than a generic machine-learning library: it is integrated with Cherenkov-telescope analysis stacks, consumes calibrated and cleaned camera data, and returns outputs that can be evaluated with standard high-energy gamma-ray performance metrics such as ROC curves, energy and angular resolution, and differential sensitivity (Nieto et al., 2019).
1. Historical development and scope
CTLearn was introduced in 2019 as a configuration-file–driven package under development for gamma-ray astronomy, with a high-level interface, TensorFlow back end, and explicit coupling to IACT data handling via DL1-Data-Handler. Its initial demonstrations emphasized gamma/hadron classification on CTA Monte Carlo data, using both a single-telescope CNN and a stereoscopic CNN-RNN architecture on the CTA southern baseline layout “S8,” which comprised 4 LSTs, 25 MSTs, and 70 SSTs. In that benchmark, the dataset contained approximately 400,000 events and approximately 4 million images, balanced between diffuse gamma-ray and proton events, with an 80%/20% train–test split (Nieto et al., 2019).
In 2021, CTLearn was extended from classification to full-event reconstruction on simulated CTA data. The monoscopic study formulated gamma/hadron separation, energy estimation, and direction reconstruction as separate tasks driven directly by pixel-wise camera images, using a Thin-ResNet-derived model on CTA LST events. The corresponding stereoscopic study introduced TRN-RNN, in which per-telescope image features extracted by a thin ResNet backbone were fused with a dynamic LSTM so that events with variable telescope multiplicity could be reconstructed at event level (Nieto et al., 2021); (Miener et al., 2021).
The framework then moved from simulation-heavy CTA studies to real observational pipelines. Within MAGIC, CTLearn was embedded into the MARS-based analysis chain and evaluated on Crab Nebula data, first in a 2021 analysis of 2.93 h of observations and then in a 2022 contribution using 5.38 h of 2016 Crab data. These papers established that deep CNN reconstruction with cleaned images could match the detection sensitivity of the conventional MAGIC pipeline on real data (Miener et al., 2021); (Miener et al., 2022).
By 2025, CTLearn had become part of a broader CTAO-oriented ecosystem. It was used for fully deep-learning–driven stereoscopic reconstruction with CTAO LST1+LST4, for deep-learning reconstruction on real Crab LST-1 data as an alternative to Random Forests, and for the first CTLearn-based waveform analysis using calibrated and cleaned waveforms rather than charge-integrated images. This progression broadened CTLearn from image-based gamma/hadron classification into a multi-instrument, multi-representation reconstruction framework spanning CTA simulations, MAGIC observational data, LST commissioning data, and waveform-level analyses (Miener et al., 18 Sep 2025); (Lacave et al., 29 Sep 2025); (Miener et al., 18 Sep 2025).
2. Software architecture and ecosystem integration
CTLearn typically occupies the reconstruction stage between low-level IACT calibration and high-level instrument-response or science analysis. In CTA and CTAO workflows, ctapipe produces calibrated, cleaned DL1-like data; DL1-Data-Handler converts these data into deep-learning–oriented tensors; CTLearn trains or applies the neural network; and ctapipe together with pyirf derives IRFs, angular and energy resolution, and sensitivity curves from the predictions. In MAGIC, the upstream role is played by MARS, which processes Monte Carlo and observational data, after which a macro exports relevant information into ROOT branches readable with uproot, and DL1-Data-Handler assembles an HDF5 dataset for CTLearn (Miener et al., 2021); (Miener et al., 18 Sep 2025).
The framework’s data model is explicitly pixel-centric. Depending on the study, inputs include per-pixel integrated charges, signal arrival times, telescope identifiers, and Monte Carlo labels such as particle class, true energy, and true direction. CTLearn reads these structured DL1 products and constructs the tensors required by the chosen architecture. Its outputs are then written in formats compatible with the surrounding analysis stack. In the CTAO studies, the predictions are written in ctapipe-compatible tables following the CTAO reference data structure, which preserves interoperability with pyirf and the Data Processing and Preservation System (Miener et al., 18 Sep 2025).
A notable design feature is its separation of concerns. DL1-Data-Handler manages geometry mapping, event-wise generators, and HDF5 organization; CTLearn defines models, training loops, and inference; and auxiliary packages such as CTLearn-optimizer and CTLearn-Manager support hyperparameter tuning, experiment orchestration, and reproducible configuration-driven workflows. The MAGIC studies also show that CTLearn can be inserted into a legacy instrument-specific chain without replacing the low-level calibration software, which remains essential for producing physically meaningful camera data (Nieto et al., 2021); (Miener et al., 2022).
This architecture makes CTLearn instrument-portable but not instrument-agnostic in the abstract. Its portability derives from explicit support for IACT conventions—hexagonal cameras, telescope multiplicity, stereoscopy, DL1 data products, and array-specific metadata—rather than from a generalized computer-vision interface. The repeated use of CTLearn with CTA, CTAO, MAGIC, and LST-1 indicates that the framework’s abstraction boundary is the reconstructed Cherenkov event, not the raw detector electronics alone (Miener et al., 2021); (Lacave et al., 29 Sep 2025).
3. Input representations and neural architectures
A central technical issue in CTLearn is camera geometry. Many IACT cameras use hexagonal pixel lattices, whereas standard 2D CNNs assume rectangular grids. The standard CTLearn solution is to map hexagonal or irregular camera layouts to Cartesian lattices by bilinear interpolation, using DL1-Data-Handler’s ImageMapper. This transformation was used in the early CTA studies, in the MAGIC pipeline, and in the CTAO LST1+LST4 analysis so that conventional convolutional layers could operate on the resulting images (Nieto et al., 2021); (Miener et al., 2021); (Miener et al., 18 Sep 2025).
CTLearn supports several event representations. In monoscopic mode, a single telescope image is passed to a CNN backbone. In the early stereoscopic CTA work, triggered telescope images were sorted by total integrated charge and processed as a variable-length sequence by TRN-RNN, where a pre-trained thin ResNet extracted a feature vector for each telescope and a dynamic LSTM combined these vectors into an event-level representation (Miener et al., 2021). In the MAGIC and CTAO stackTRN studies, stereoscopy was encoded differently: images from the participating telescopes were stacked channel-wise before entering a CNN. For two telescopes with charge and timing channels, this yields a four-channel input tensor in which telescope identity and per-pixel observables are encoded in the channel dimension (Miener et al., 2021); (Miener et al., 18 Sep 2025).
The dominant backbone family in the literature is Thin-ResNet. In the MAGIC and CTAO studies, TRN is described as a shallow residual neural network with 33 layers, residual or skip connections, and dual squeeze-and-excitation attention in each residual block. In the CTAO LST1+LST4 analysis, the “CTLearn-stackTRN” model skips the first initialization layer of the original TRN in order to match the LST input shape. In the 2021 monoscopic CTA study, the corresponding TRN-single-tel model used a deep CNN with residual connections and SE attention together with a selectable fully connected head for classification or regression (Nieto et al., 2021); (Miener et al., 2022); (Miener et al., 18 Sep 2025).
The framework also distinguishes between cleaned and raw images. In the MAGIC real-data studies, separate Thin-ResNet models were trained on raw images and on cleaned images. Raw images contained Cherenkov signal together with night-sky-background fluctuations, whereas cleaned images inherited the MARS cleaning mask, with noise-dominated pixels set to zero. This distinction proved operationally important: the real-data gap between raw-image and cleaned-image performance was one of the clearest demonstrations that MC–data mismatch in NSB can dominate deep-learning reconstruction if the input representation is not controlled (Miener et al., 2021).
A later extension replaces integrated images with waveforms. In the 2025 LST waveform study, CTLearn ingested calibrated waveforms cropped to 20 samples of 1 ns per pixel, still after standard image cleaning, and restricted the analysis to events whose image contained more than 50 photoelectrons after cleaning. The paper explicitly frames this as the first IACT waveform analysis based on deep CNNs using CTLearn, and it preserves the same TRN architecture family rather than introducing a separate waveform-specific model class (Miener et al., 18 Sep 2025).
4. Reconstruction tasks and evaluation methodology
CTLearn is consistently used for full-event reconstruction, meaning three tasks: particle classification, energy regression, and arrival-direction regression. The classifier outputs a gamma-likeness score, usually called gammaness in the CTA/CTAO studies and hadronness or gamma probability in the MAGIC context; the regressors predict reconstructed energy and reconstructed direction from the same event images (Miener et al., 2021); (Miener et al., 18 Sep 2025).
The standard evaluation metrics are native to IACT analysis rather than generic machine-learning benchmarks. For classification, ROC curves and AUC quantify gamma/hadron separation. For direction reconstruction, angular resolution is defined as the 68% containment angle of reconstructed gamma-ray events around the true source direction. In the CTAO stereoscopic study this is written as
with satisfying a 68% containment condition in each energy bin. For energy reconstruction, the error variable is
and the energy resolution is the 68% containment of this distribution in each true-energy bin (Miener et al., 18 Sep 2025).
Sensitivity is treated in instrument-specific but related ways. In the MAGIC analyses, sensitivity is defined as the source strength that yields
after 50 h of observation, together with an excess-to-background requirement of more than 5%, and it is expressed as a percentage of the Crab flux (Miener et al., 2021); (Miener et al., 2022). In the CTAO LST1+LST4 study, differential sensitivity per reconstructed energy bin requires more than significance, at least ten detected gamma rays, and a minimum excess-over-background ratio of 0.05 for 50 h, with significance computed using Li and Ma Eq. 17 (Miener et al., 18 Sep 2025).
The studies also use analysis cuts in a way that parallels conventional pipelines. In CTAO, energy-dependent gammaness cuts are selected to retain fixed fractions of gamma-ray events such as 40%, 70%, and 90% in each reconstructed-energy bin (Miener et al., 18 Sep 2025). In MAGIC, CTLearn adopts exactly the same quality cuts as MARS for , image size, and stereo validity, and the hadronness cut is tuned to match the background rate of the conventional analysis. This is methodologically significant because it isolates the reconstruction model as the primary variable in the comparison (Miener et al., 2021).
5. Empirical performance across CTA, CTAO, MAGIC, and LST-1
The earliest broad benchmark showed that CTLearn already provided competitive classification performance before full-event reconstruction was fully developed. On the CTA S8 simulation, the single-telescope model reached test AUC values between 0.778 and 0.866 depending on telescope design, while the CNN-RNN stereoscopic model reached AUC values between 0.815 and 0.909 without quality cuts; with a telescope multiplicity cut of at least four triggered telescopes, the CNN-RNN AUC exceeded 0.90 for all telescope designs and reached up to 0.98 for all MST designs and SST-1M (Nieto et al., 2019).
In the monoscopic CTA full-event study, the TRN-single-tel model on simulated LST events achieved a classification accuracy of and AUC of for all events, improving to accuracy and AUC for contained events. In the stereoscopic CTA study, TRN-RNN reached classification AUC values of 0.98 for 4 LSTs, 0.994 for 13 MSTs, and 0.996 for 40 SSTs, with best energy resolutions of approximately 10%, 7%, and 6% respectively; the same study, however, identified direction reconstruction as the weakest component, with angular resolution at the highest energies significantly worse than the conventional Eventdisplay-based analysis (Nieto et al., 2021); (Miener et al., 2021).
The MAGIC real-data results are especially consequential because they compare CTLearn directly with a mature operational pipeline. In the 2.93 h Crab analysis, CTLearn trained on cleaned images matched MARS in both medium- and low-energy regimes. At 0, the cleaned-image CTLearn model reported a gamma rate of 1, background rate of 2, and sensitivity of 3 Crab, compared with MARS values of 4, 5, and 6 Crab. At 7, the cleaned-image CTLearn model gave 8, 9, and 0 Crab versus MARS values of 1, 2, and 3 Crab. The raw-image models were substantially worse, which the authors associated with NSB mismatch between Monte Carlo and data (Miener et al., 2021).
A later MAGIC contribution using 5.38 h of Crab data reported the same qualitative result with different observing material: at medium energy, CTLearn obtained a sensitivity of 4 Crab compared with 5 for MARS, and at low energy 6 Crab compared with 7. The corresponding Li and Ma significances were 8 versus 9 in the medium-energy analysis and 0 versus 1 in the low-energy analysis, again indicating near-identity between the deep-learning and conventional chains under matched cuts (Miener et al., 2022).
The 2025 CTAO stereoscopic study advanced the comparison further by evaluating CTLearn-generated IRFs against the reference CTAO prod5 LST subarray. For energies below 2, the CTLearn-stackTRN model for LST1+LST4 achieved better angular resolution than the reference CTAO prod5 performance of 4 LSTs, and its differential sensitivity below 3 matched the reference 4-LST performance despite using only two telescopes. Training on 2 NVIDIA GH200 GPUs required less than 3 hours, and inference on the full evaluation dataset took less than 15 minutes on a single GH200 (Miener et al., 18 Sep 2025).
On real LST-1 Crab data, CTLearn was studied in two operational modes: a single universal tri-model trained across all relevant Crab pointings, and ten specialized multi-models each covering an altitude band of approximately 4. The multi-model approach provided clearly better energy resolution at low energies below roughly 500 GeV, whereas the single model delivered better angular resolution across the full energy range and, most importantly, better differential sensitivity. The paper therefore identified the single model as the better general-purpose analysis option and suggested a hybrid strategy in which multi-model output is used for energy while single-model output is used for direction and classification (Lacave et al., 29 Sep 2025).
6. Limitations, systematics, and research directions
A recurring limitation is dependence on Monte Carlo realism. The MAGIC papers showed that raw-image CNNs are sensitive to differences between simulated and real NSB conditions; performance improved when cleaned images were used, and the authors explicitly noted that pixel-wise tuning of NSB noise in MC to match each observation could improve raw-image training (Miener et al., 2021). The CTAO LST1+LST4 study similarly emphasized that its results were obtained exclusively from MC simulation restricted to one telescope pointing in the sky, so generalization to real data and varying pointings remains a necessary validation step (Miener et al., 18 Sep 2025).
A second limitation concerns array complexity. TRN-RNN was designed to handle variable-length telescope sequences, but later channel-stacking approaches such as CTLearn-stackTRN were demonstrated only for fixed two-telescope stereo events. The 2025 CTAO paper states that the variable telescope multiplicity problem and hybrid LST/MST/SST combinations are not tackled explicitly in that study. This suggests that future CTLearn development will likely depend on more flexible per-telescope fusion strategies, whether recurrent, attention-based, or graph-structured (Miener et al., 2021); (Miener et al., 18 Sep 2025).
Direction reconstruction has been uneven across studies. The 2021 stereoscopic CTA work reported excellent classification and energy reconstruction but explicitly stated that TRN-RNN performed poorly on arrival-direction reconstruction, and suggested that including telescope position information might help. By contrast, later stackTRN and MAGIC real-data studies showed that angular performance can reach conventional-pipeline levels when the geometry, multiplicity, and preprocessing are better controlled (Miener et al., 2021); (Miener et al., 2022).
The waveform line of work introduces both opportunity and cost. The first CTLearn waveform analysis on LST data bypassed charge integration and handcrafted feature extraction by using calibrated waveforms directly, but the study also reported a time-intensive training process spanning several weeks on high-performance hardware. It therefore did not propose the waveform method as a replacement for the standard pipeline for routine observations; instead, it positioned waveform-based CTLearn as particularly relevant for targeted analyses of scientifically significant or rare events, and as a precursor to waveform-based DBSCAN cleaning and AI-driven trigger systems for future cameras such as AdvCam (Miener et al., 18 Sep 2025).
The most persistent development themes are deeper architectures, multi-task learning, uncertainty handling, and domain adaptation. The early monoscopic and MAGIC papers repeatedly describe the selected Thin-ResNet variants as relatively shallow and suggest that increasing model depth or complexity could improve performance. Other proposed directions include evaluation under varying zenith angles, NSB levels, and atmospheric states; transfer learning from general to pointing-specific models; uncertainty-aware models such as Bayesian CNNs or ensembles; and end-to-end integration with real commissioning data from LST stereoscopy and, eventually, full CTAO North and South arrays (Nieto et al., 2021); (Miener et al., 2021); (Lacave et al., 29 Sep 2025).
In aggregate, CTLearn has evolved from a TensorFlow-based CNN package for Cherenkov-image classification into a reconstruction framework that can match established IACT analyses on real data, interoperate with instrument-specific and CTAO-standard software stacks, and absorb richer input representations such as waveform cubes. Its published trajectory indicates that its principal scientific importance lies less in any single architecture than in the establishment of a reproducible deep-learning layer inside operational IACT reconstruction pipelines (Nieto et al., 2019).