Why Filtering by Photon Number Matters?
Photon-number-resolving (PNR) detectors provide considerably more information than conventional binary single photon detectors by assigning each detection event to a specific photon-number state. In many experiments, however, determining the photon number is only the first step. Researchers often wish to isolate specific events, for example single-photon detections during detector characterization, multi-photon events in correlation measurements, or heralding events in quantum optics experiments such as in quantum communication and photonic quantum computing.
Instead of performing this classification offline after the measurement, real-time photon-number filtering enables photon-number-specific event streams to be generated as data are acquired. This provides immediate feedback during experiments and enables live detector optimization, interactive data analysis, and advanced measurement schemes based on selected photon-number states.
In the following sections, we demonstrate how multidimensional time-tagged data can be transformed into separated photon-number regions and converted into arrival-time gates for efficient near-real-time processing.
From Detector Pulses to Photon-Number Information
The analysis presented here is based on intrinsic PNR, where the photon number is encoded directly in the electrical pulse shape of a single superconducting nanowire single-photon detector (SNSPD). Similar to a previous article on high-count-rate PNR analysis, multiple timing observables are extracted from each detector pulse instead of recording the complete waveform.
A mode-locked laser producing 2.5 ps (FWHM) optical pulses at a repetition rate of 2 MHz was attenuated to the few-photon regime and detected using a single channel of an interleaved SNSPD from Single Quantum with an intrinsic timing jitter of 18.7 ps (FWHM). Within 20 ns the detector recovers to more than 95% of its bias current, allowing recovery-induced pulse distortions to be neglected.

The detector output was split into two timing channels to record the rising- and falling-edge threshold crossings relative to the laser synchronization signal using the HydraHarp 500. Plotting these timing observables in a 2D histogram reveals distinct clusters corresponding to different photon-number states. The position of each event within this multidimensional timing space therefore provides the information required to infer the detected photon number.
Improving Photon-Number Separation
Although the photon-number information is already visible in the raw 2D histogram, the clusters are tilted and elongated, making it difficult to define robust photon-number gates directly. The PNR Manipulator, available in both UniHarp and the snAPI Python wrapper, provides a sequence of coordinate transformations that optimize the separation of the photon-number states.
The first step is the Time-over-Threshold (ToT) transformation, which combines the rising and falling-edge time tags into a pulsewidth coordinate while preserving the arrival-time information. Since pulsewidth depends strongly on the photon number, this transformation already increases the separation between neighboring clusters.
Next, the Time-Walk Factor applies a linear shearing transformation to compensate for the remaining correlation between the two timing observables. This aligns the photon-number clusters with the coordinate axes, producing a representation in which the photon-number states are more compact and better separated.

Arrival-Time Gating
Once the photon-number clusters have been optimized, the PNR Manipulator projects the multidimensional time tag data onto a single axis. This results in the 1D histogram shown, where photon-number states occupy distinct arrival-time regions.
Building on this representation, the Herald Manipulator allows users to define configurable arrival-time gates corresponding to individual photon-number states. Events falling within each gate are assigned to „virtual channels“, enabling photon-number-specific event streams that can be processed independently by subsequent manipulators.

For well-separated photon-number states, this approach provides an efficient and intuitive means of classifying detection events. Neighboring photon-number distributions may, however, partially overlap. In these regions, the photon number can only be assigned with a finite confidence determined by the detector response and the chosen gate boundaries.
More sophisticated post-processing methods, such as principal component analysis (PCA) or Gaussian mixture models (GMMs), can further improve the classification of overlapping events by exploiting additional waveform information or probabilistic models. These approaches typically maximize photon-number discrimination accuracy but require substantially greater computational effort. In contrast, the deterministic coordinate transformations implemented in the PNR and Herald Manipulators provide a lightweight workflow that is well suited for interactive analysis and near-real-time processing.
Near-Real-Time Processing in Software
The complete workflow described in this article is implemented in UniHarp and can also be accessed programmatically through the snAPI Python interface. The accompanying video demonstrates how multidimensional time tag data are transformed using the PNR Manipulator and subsequently converted into photon-number-specific event streams using Herald Manipulators in the UniHarp GUI. All transformations are applied interactively, allowing users to immediately visualize their effect and optimize the photon-number separation during an ongoing measurement.
Because the analysis relies on deterministic coordinate transformations rather than computationally intensive waveform classification, photon-number filtering can be performed efficiently as data are acquired. The resulting event streams remain fully compatible with the standard TTTR workflow and can be forwarded directly to subsequent analysis routines.
This enables a wide range of applications, including live detector characterization, photon-number-resolved correlation measurements, heralded quantum optics experiments, and real-time monitoring of selected photon-number states. By transforming multidimensional timing information into configurable arrival-time gates, UniHarp turns intrinsic photon-number resolution from an offline post-processing task into a practical tool for interactive experiments and high-throughput quantum photonics.

Bring Real-Time Photon-Number Processing into Your Workflow
Learn how UniHarp and the snAPI Python interface enable interactive photon-number filtering, multidimensional time-tag analysis, and flexible data processing for advanced quantum optics experiments.





























