\documentclass[aps,pra,twocolumn, superscriptaddress]{revtex4}
% \documentclass[IEEEtran, superscriptaddress]{revtex4}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{hyperref}
\setlength{\paperheight}{11in}

\newcommand{\ket}[1]{|{#1}\rangle}
\newcommand{\bra}[1]{\langle{#1}|}
\newcommand{\OD}[0]{\mathrm{OD}}
\usepackage{color}

\begin{document}
\title{Photon number and timing resolution of a near-infrared continuous-wave source with a transition-edge sensor}

\author{Jianwei Lee}
\email[]{jianwei.lee@u.nus.edu}
\affiliation{Center for Quantum Technologies, National University of
  Singapore, 3 Science Drive 2, Singapore, 117543}
\author{Lijiong Shen}
\affiliation{Center for Quantum Technologies, National University of
  Singapore, 3 Science Drive 2, Singapore, 117543}
\affiliation{Department of Physics,
             National University of Singapore,
             2 Science Drive 3,  Singapore, 117542}
\author{Alessandro Cer{\`e}}
\affiliation{Center for Quantum Technologies, National University of
  Singapore, 3 Science Drive 2, Singapore, 117543}

\author{Thomas Gerrits}
\affiliation{National Institute of Standards and Technology (NIST), 
325 Broadway, Boulder, 
Colorado 80305, USA}
\author{Adriana E. Lita}
\affiliation{National Institute of Standards and Technology (NIST), 
325 Broadway, Boulder, 
Colorado 80305, USA}
\author{Sae Woo Nam}
\affiliation{National Institute of Standards and Technology (NIST), 
325 Broadway, Boulder, 
Colorado 80305, USA}
\author{Christian~Kurtsiefer}
\affiliation{Center for Quantum Technologies, National University of
  Singapore, 3 Science Drive 2, Singapore, 117543}
\affiliation{Department of Physics,
             National University of Singapore,
             2 Science Drive 3,  Singapore, 117542}

%\homepage[]{Your web page}
%\thanks{}
\date{\today}
\begin{abstract}
  Transition-edge sensors (TES) are calorimetric spectrometers that have near unit efficiency and are photon-number resolving.
  A recovery time on the order of microseconds, however, limits the number
  resolving ability and timing accuracy in high photon-flux conditions.
  This can be addressed by pulsing the light source or discarding overlapping
  signals, thereby limiting its applicability.
  A method that works for stationary light sources uses the differentiated TES
  signal to determine the detection time of overlapping signals and to count
  photons~\cite{Fowler:2015ef}. However, the low signal-to-noise ratio of TES
  response when detecting near-infrared photons complicates the direct
  estimation of their detection times by this method.
  Here, we present an alternative approach where we use 
  a discriminator inherently robust against noise to coarsely locate pulses in time, 
  the integral of the identified signal regions to count photons, 
  and a separate fit to determine the exact detection instant.
\end{abstract}

% insert suggested PACS numbers in braces on next line
% \pacs{37.10.Gh,% Atom traps and guides
% 42.50.Ct,       % Quantum description of interaction of light and matter;
%                 % related experiments
% 32.90.+a        % Other topics in atomic properties and interactions of atoms;
%                 % with photons (restricted to new topics in section 32)
% }

\maketitle
\section{Introduction}
Transition-edge sensors were introduced as calorimetric photodetectors based
on superconductors for soft X-rays in the past, but have been optimized more
recently to work as wide-band, photon-number resolving detectors to absorb 
$\textgreater95\%$ of incident photons at near infra-red (NIR) 
wavelengths~\cite{Lita:08}. 
This high single photon quantum efficiency was instrumental to an experiment on
a loophole-free violation of Bell's inequality~\cite{Giustina:2015}.
 
Detection of a single photon by the TES leads to an electric pulse response
with a fast (tens of nanoseconds) rising edge, and a decay with a time
constant of a few microseconds~\cite{Lita:2010}.
% Standard techniques for time-tagging a detection event, based on threshold crossing or constant fraction discrimination, do not work when two pulses have a large overlap, limiting the applicability of the TES for high photon-flux detection.
Straightforward application of time-tagging techniques, 
such as threshold crossing or constant fraction discrimination (CFD), 
work well when the pulses are isolated.
However, when multiple pulses overlap, 
they may be incorrectly identified as a single event.
Consequently, the apparent number of photons detected is reduced.

To deal with overlapping pulses, several methods have been developed for particle and high-energy radiation detection~\cite{Fowler:2015ef,BELLI2008512,Tambave2012,Vencelj2009,Marrone2006}. 
% Alternatively, the overlap can be reduced so that detection times can be determined with conventional methods. However, 
%
In~\cite{Fowler:2015ef}, Fowler et al. used differentiation in time to better locate the steep rising edge of individual photodetection events when the signals are overlapped:
the number of rising edges
% detected
corresponds to the number of detected photons.
The detection times and photon number were then used to initialise a fit to a multi-photon model.
This works well when signal-to-noise ratio is high, which is common for the
detection of high-energy photons like $\gamma$ and X-rays.
%
% Alternatively, peak detection algorithms may be used~\cite{BELLI2008512}, 
% or the pulses can be reshaped~\cite{Tambave2012}, 
% to locate each underlying pulse. 
% Alternatively, a peak detection algorithm may be used to locate each underlying pulse, but is vulnerable to false triggering when signal and noise peaks occur on a similar time scale~\cite{BELLI2008512}.

% It is also possible remove the exponential tail of each underlying pulse using a 
% Moving Window Deconvolution (MWD) filter 
% such that detection times can be retrieved once again using a CFD.
% However, the CFD is also vulnerable to false triggering
% by fluctuations along the signal peak.
% Furthermore, the filtered signal does not accurately indicate 
% the amplitude of the individual photon pulses~\cite{Tambave2012}.
For near-infrared (NIR) photons detected with a TES, 
the signal-to-noise ratio is relatively low (SNR=2.4~\cite{LamasLinares:2013fk}),
and timing accuracy is affected by the bandwidth limitations necessary to reject false positives.
% limiting its use to pulsed light sources.

In this work,
we adopt a different approach. 
We use a 2-level discriminator together with 
signal integration to count photons 
emitted from a NIR continuous wave (CW) source, 
centered at 810~nm.
%
The discriminator does not trigger for noise fluctuations 
smaller than the difference between the two levels.
%
We then apply least-squares fitting to the signal
to recover the amplitudes and detection times of the underlying photon pulses.

\section{Electronics and photon detection pulse}\label{sec:electronics}
We use Tungsten-based TESs provided by a collaboration with NIST~\cite{Lita:08}.
The devices are kept at a temperature of 80~mK using an adiabatic demagnetization refrigerator (ADR) cryostat (Entropy Cryogenics).
The first amplification stage consists of a SQUID Series Array (Magnicon C6),
followed by further signal conditioning at room temperature (Magnicon
electronics XXF-1~\cite{Drung:2007iu}) with an overall amplification bandwidth
of $\approx 6$~MHz.
The amplifier output has a RMS noise of 1.8~mV.
The low frequency components of the noise result in a slowly varying baseline in every trace.
We minimise this by operating the SQUID in a flux-locked loop~\cite{Drung:2007iu}.
We record 10~$\mu$s long traces with a sampling rate of 0.5~GS/s
on oscilloscope with a vertical resolution of 12~bit.

In the rest of this work we indicate the signal as a function of time as~$V(t)$.
To characterize the TES response, we use a laser diode~(LD) centered at 810~nm as a light source, operated in continuous~(CW) mode.
% We can drive the LD with train of pulses as short as 4~ns, or in free running mode.
We control the average photon number with a variable attenuator, then launch
the light into a single mode fiber (type SM28e) that directs it to the
sensitive surface of the TES.

For light at 810~nm, the signal after the amplifier chain exhibits a rise time for a single photon pulse in the order of 100~ns,
and an overall pulse duration of 2~$\mu$s.
For every recorded pulse trace, we remove the varying baseline,
% median of the signal below a predefined threshold $V_{\text{high}}$:
\begin{equation}
    V'(t) = V(t) - V_y
\end{equation}
where  $V_y$ is the most frequently occurring value of the discretized signal
$\left(V(t)\right)$ over the sampling interval.

\section{Pulse Identification}\label{sec:disc}
\begin{figure}
\includegraphics[width=1\linewidth]{figures/comparator/comparator_at_233ns.eps}
  \caption{\label{fig:disc}
    (a) Two overlapping pulses separated by 233~ns arrive at about $3~\mu$s. 
    The rising edge of the later pulse is obscured by the earlier pulse and prevents detection time estimation using the crossing-time at threshold $V_{\text{high}}$.
    (b) A two-level discriminator identifies the region CD containing the rising edges of the overlapping pulses. 
    This is the most relevant region of the pulse to consider when identifying the detection times of photons.
    The region is used to initialise a least-square fit of the signal to a TES response model in order to determine the detection time of the obscured pulse.
    % It can be used to initialise subsequent algorithms that fit the signal to a multi-photon model, returning the detection times of individual pulses. 
    We extend the region by $\Delta t$ to include the full pulse when we want to consider its integral. The integral, being proportional to the energy absorbed, is used to count photons.
    % The comparator consists of an OR operation performed between a conventional SET-RESET edge detection logic forward (green line) and backward (red line) along the signal.
    We discard regions that contain partially captured pulses, 
    such as the one appearing on the right edge of the acquisition window.
    }
\end{figure}
% For CW detection,
% it is not possible to rely on an external trigger.
% To identify
% photodetection events
% we use
% the digital equivalent of SET-RESET latch edge detection,
% with SET triggered when the signal passes threshold~$V_{\text{high}}$
% and RESET by the first subsequent zero crossing.
We use
the digital equivalent of SET-RESET latch edge detection to detect pulses,
with SET triggered when the signal passes threshold~$V_{\text{high}}$ (Fig.~\ref{fig:disc}~point A)
and RESET by the first subsequent crossing of threshold~$V_{\text{low}}$ (point B).
% The use of two distinct thresholds prevents false triggers due to noise fluctuations around a single threshold.

\begin{figure}
\includegraphics[width=1\linewidth]{figures/height_histogram_cw/height_histo.eps}
    \caption{\label{fig:height_histo}
        Maximum TES signal distribution to a continuously running LD with~$\bar{n} = 0.25$. The two peaks correspond to 0 and at least 1 photon being detected respectively. Error bars indicate Poissonian standard-deviation.
        Black arrow: Point of minimal overlap between Gaussian fits to the two height distributions corresponding to $V_{\text{high}} = 7.9$~mV.}
\end{figure}
We determine the threshold~$V_{\text{high}}$ by considering the distribution of the maximum height of a sample of~$4\times10^4$ traces.
The resulting histogram (see Fig.~\ref{fig:height_histo}),
clearly shows two peaks.
The lowest voltage peak corresponds to traces without any detection event~($n=0$), the second one to traces with at least one detection event~($n>0$).
We set~$V_{\text{high}}$ to the value that minimizes the overlap between the two distributions
while $V_{\text{low}}$ is set to 0~V.

\section{Photon Number Discrimination}\label{sec:number_discrimination}
The number of distinct edges identified by the discriminator
is not an indication of the number of photodetection events because closely overlapping pulses may be incorrectly identified as a single event.

To determine the number of photodetection events, we assume that the detection
and subsequent amplification have a sufficiently linear response,
so that the integral of each signal is proportional to the energy absorbed~\cite{Cabrera2000509}.

To increase signal-to-noise ratio, we use the discriminator to identify integration windows surrounding photodetection events (Fig.~\ref{fig:disc}b).

% We ensure the inclusion of both the leading edge and the decaying tail by extending the discrimination window in Fig.~\ref{fig:disc}b by $\Delta t = 1300$~ns (Fig.~\ref{fig:disc}c).

The initially selected region AB identified by the two-level discriminator
contains only a fraction of the leading edge  belonging to the first pulse.
To ensure its inclusion,
we consider the first low crossing (point C) before point A as the starting
point of the pulse window.

To include the decaying tail, 
we cannot rely on the crossing of the low threshold (point B),
as the signal-to-noise ratio in this region is low.
Instead, we extend the integration window by a duration $\Delta t$ after the last high crossing (point D).
% We instead consider the last high crossing (point D)
% and extend it by the duration $\Delta t$.

We then compute the pulse area $a$ for every trace,
and organize them in histogram $C(a)$.
We empirically found a duration $\Delta t = 1300$~ns to optimise the photon-number resolution of $C(a)$.

\begin{figure}
\includegraphics[width=1\linewidth]{figures/area_histogram_cw/area_histos_comparison.eps}
    \caption{\label{fig:area_histos_comparison}
    Area distribution of $10~\mu$s long traces obtained with different methods:
    % The energy absorbed can be obtained by integrating the TES signal. We use this to count photons centered at 810~nm.
    % A straighforward integration includes regions not associated with photodetection (Red line).
    Straightforward integration of the signal above threshold $V_{\text{high}}$ (Dashed line) 
    does not yield good photon-number resolution, 
    as it excludes the rising edge and decaying tail of the pulse below threshold.
    Better resolution is obtained by integrating full pulses identified with a 2-level discriminator 
    while rejecting partial pulses at the edge of the signal traces (Solid line). 
    % The discriminator rejects partial pulses, improving photon-number resolution between complete photodetection events.
    }
\end{figure}

In this work,
we collect traces of finite duration equal to $10~\mu$s,
resulting in partial pulses being recorded at the edges of the acquisition window.
We reject these events 
to avoid degradation of pulse-integral distinguishably 
between signal regions containing complete pulses.

To illustrate the photon number resolving ability of this method, we compare
the area histogram obtained with this method with one obtained from integrating the
portion of the trace above $V_{\text{high}}$ in Fig.~\ref{fig:area_histos_comparison}.
Evidently, the integral distribution obtained using the 2-level discriminator, 
with partial pulse rejection, has a better resolution power, as events for one
or two photons, as well as cases with noise only, can clearly be distinguished
from each other.

To obtain clear regions for $n=0,1,2\ldots$ photons, we fit the distribution $C(a>a_{t_{01}})$ corresponding to $n>0$ detection events to the sum of Gaussian peaks~$G_n(a; a_n, \sigma_n)$:

\begin{equation}
    C(a>a_{t_{01}}) = N\,\sum_{n=1}^{n_{max}}P(n|\bar{n})\,G_n(a;a_n, \sigma_n)\,,
\end{equation}
with coefficients $P$ following a Poissonian distribution with average~$\bar{n}$ and
$N$ the total number of traces.

% We calibrate the detector by classifying a trace with integral $a \in [a_n-2\,\sigma_n,a_n+2\,\sigma_n]$ as an $n$-photon event.
% We calibrate the detector by classifying a trace with integral $a \in [a_{mn}},a_{no}}]$ as an $n$-photon event.


The Gaussian distributions corresponding to 1 and 2 photons in Fig.~\ref{fig:area_histo} demonstrates near linear dependence of the integral with photon energy ($a_2/a_1 = 1.98$).

We determine the minimum overlap between $G_1(a; a_1, \sigma_1)$ and $G_2(a; a_2, \sigma_2)$ to be the threshold $a_{t_{12}}$. 
At this threshold, 
the probability of falsely identifying an $n=1$ trace as an $n=2$ trace is 0.6\%,
while
the probability of falsely identifying an $n=2$ trace as an $n=1$ trace is 0.8\%.

\begin{figure}
\includegraphics[width=1\linewidth]{figures/area_histogram_cw/area_histo_with_fit.eps}
    \caption{\label{fig:area_histo}
        Pulse area distribution $C(a)$ of the signal in the discriminated region.  
        % The first bin ($a = 0$) corresponds to zero photodetection events being discriminated.
        % The small distribution to the left of $a_{t_{01}} = 5.6$~mV$\,\mu$s corresponds to traces with detector noise exceeding $V_{\text{high}}$.
        Events with area below $a_{t_{01}}$ are classified as containing zero photons.
        Gaussian distributions fitted to the $n=1$ (Blue) and $n=2$ (Red) area distributions
        have a minimal overlap at $a_{t_{12}}$.
        At this threshold, the probability of falsely attributing the detection of a single photon to a trace containing $n=2$ photons is 0.6\%.
        % Threshold $a_{t12}$ distinguishes $n=1$ (Blue) from $n=2$ (Red) photon events.
        % Equally separated peaks corresponding to 1, 2, 3 and 4 photons demonstrates the linear dependence of the integral with photon energy. 
        Error bars indicate Poissonian standard-deviation.}
\end{figure} 
% \vfill\null
\section{Determining the detection times of overlapping pulses}
To determine the detection times of overlapping pulses, 
we rely on least-squares fitting of the signal $V'(t)$
to a multi-photon model $V'_{\text{model}}(t)$ comprising of a linear superposition of $N$ single-photon models 
$V_{p1}(t-t_n)$:
\begin{equation}\label{eqn:model}
    V'_{\text{model}}(t) = \sum_n^N\,A_n\,V_{p1}(t-t_n)\,,
\end{equation}
where $N$ is the number of photons detected within the discriminator window,
$t_n$ the detection time, and $A_n$ the maximum pulse amplitude of the $n$-th photon.
% We associate the steep rising edge of the pulse to photon arrival.
% The discriminated region BD contains only the partial leading edge of the first pulse, 
% and includes the decaying tail not associated with photon arrival.
% We modify the discriminator region BD to 
% (i) include the full rising edge of the first pulse (point A) by searching the trace for the threshold crossing of~$V_{\text{low}}$ just before point A.
% (ii) exclude the decaying tail below~$V_{\text{high}}$ by searching the trace for the threshold crossing of~$V_{\text{high}}$ (point C) just before point B.
We improve the quality of the fit
by restricting the time window to the region most relevant to 
the arrival of the photons (Fig.~\ref{fig:disc} region CD). An example of the fit result is shown in Fig.~\ref{fig:fit}.

\begin{figure}
    \includegraphics[width=1\linewidth]{figures/lmfit_components_233ns/lmfit_components_233ns.pdf}
    \caption{\label{fig:fit}
    Fit (black) of a 2-photon signal (grey) composed of individual single photon events (red, blue) separated by 233~ns, comparable to twice the rise time of a single photon pulse. 
    %
    The single photon model was obtained by averaging the TES response to $10^4$ single photon events.
}
\end{figure}

% We fit the histogram to a sum of gaussian peaks $G(h; h_i,\sigma_i)$:
% \begin{equation}
% C(h) = N\,P(0|\bar{n})\,G(h; h_0,\sigma_0) + N\,(1-P(0|\bar{n}))\,G(h; h_{ph},\sigma_{ph})
% \end{equation}
% with $P$ following a Poissonian distribution with average~$\bar{n}$ and
% $N=10000$ the total number of sampled traces.
% We determine the height that corresponds to the minimum overlap between the two distributions to be the SET level $V_{\text{high}}$.

\section{Conclusion and future work}\label{sec:conclusion}
In conclusion, we have successfully 
resolved between $n=0, 1$ and $2$ photons
from a CW NIR source, 
using the signal integral 
evaluated in the time window 
identified by a two-level discriminator.

% We used the two-level discriminator to identify an optimal time window
% surrounding photodetection events.
The time window includes a greater fraction of the TES pulse 
relevant to photodetection
that is usually omitted by a single-threshold discriminator.
By considering an optimal fraction of the pulse profile,
we obtained pulse integral distributions sufficient to resolve between photon numbers.
%
This technique provides an alternative to photon counting 
using edge detection on the differentiated signal, 
especially when signal-to-noise ratio is low. 

We have also demonstrated how the discriminator can be applied to provide 
a range of values for the detection times of several photons.
We can use this range to initialise a least-squares fit of a signal 
containing several overlapping TES pulses to a multi-photon model,
returning the amplitudes and detection times of the individual photons.
The fit accuracy of this procedure is currently being characterised.
% model composed of a linear sum of $N$ single-photon models ($V_{p1}(t)$):
% \begin{equation}\label{eqn:model}
% V_{model}(t) = \sum_1^N A_nV_{p1}(t-t_n)
% \end{equation}
% The fit returns the amplitudes $A_n$ and detection times $t_n$ of individual pulses.
% \bibliographystyle{IEEEtran}
\bibliography{pulse_fitting_cpr.bib}

\end{document}
