\chapter{Data analysis}
\label{cha:data_analysis}
This chapter presents initial analysis on subsets of the collected data.
Purposes of the analysis include:
\begin{itemize}
  \item testing the analysis chain;
  \item verification of the experimental method, specifically the
    normalisation of number of stopped muons, and particle identification
    using specific energy loss;
  \item extracting a preliminary rate of proton emission from aluminium.
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Number of stopped muons normalisation}
\label{sec:number_of_stopped_muons_normalisation}
The active silicon target runs was used to check for the validity of the
counting of number of stopped muons, where the number can be calculated by two
methods:
\begin{itemize}
  \item counting hits on the active target in coincidence with hits on the
    upstream scintillator counter;
  \item inferred from number of X-rays recorded by the germanium detector.
\end{itemize}
This analysis was done on a subset of the active target runs
\numrange{2119}{2140} because of the problem of wrong clock frequency found in
the data quality checking shown in \cref{fig:lldq}. The data set contains
%\num[fixed-exponent=2, scientific-notation = fixed]{6.4293720E7} muon events.  
\num{6.43E7} muon events.  

\subsection{Number of stopped muons from active target counting}
\label{sub:event_selection}
Because of the active target, a stopped muon would cause two coincident hits on
the muon counter and the target. The energy of the muon hit on the active
target is also well-defined as the narrow-momentum-spread beam was used. The
correlation between the energy and timing of all the hits on the active target
is shown in \cref{fig:sir2f_Et_corr}. The most intense spot at zero time
and about \SI{5}{\MeV} energy corresponds to stopped muons in the thick target.
The band below \SI{1}{\MeV} is due to electrons, either in the beam or from
muon decay in orbits, or emitted during the cascading of muon to the muonic 1S
state.  The valley between time zero and 1200~ns shows the minimum distance in
time between two pulses. It is the mentioned limitation of the current pulse
parameter extraction method where no pile up or double pulses is accounted for. 

\begin{figure}[htb]
  \centering
    \includegraphics[width=0.85\textwidth]{figs/sir2_sir2f_E_t_corr}
  \caption{Energy - timing correlation of hits on the active target.}
  \label{fig:sir2f_Et_corr}
\end{figure}

The hits on the silicon active target after 1200~ns are mainly secondary
particles from the stopped muons:
\begin{itemize}
  \item electrons from muon decay in the 1S orbit
  \item products emitted after nuclear muon capture, including: gamma, neutron,
    heavy charged particles and recoiled nucleus 
\end{itemize}
It can be seen that there is a faint stripe of muons in the time larger than
1200~ns region, they are scattered muons by other materials without hitting the
muon counter. The electrons in the beam caused the constant band below 1 MeV and 
$t > 5000$ ns (see \cref{fig:sir2_1us_slices}).
\begin{figure}[htb]
  \centering
    \includegraphics[width=0.85\textwidth]{figs/sir2_sir2f_amp_1us_slices}
  \caption{Energy deposit on the active target in 1000 ns time slices from the
    muon hit. The peaks at about 800 keV in large delayed time are from
    the beam electrons.}
  \label{fig:sir2_1us_slices}
\end{figure}

From the energy-timing correlation above, the cuts to select stopped muons are:
\begin{enumerate}
  \item has one hit on muon counter (where a threshold was set to reject MIPs),
    and the first hit on the silicon active target is in coincidence with that
    muon counter hit: 
    \begin{equation}
      \lvert t_{\textrm{target}} - t_{\mu\textrm{ counter}}\rvert \le \SI{50}{\ns}
      \label{eqn:sir2_prompt_cut}
    \end{equation}
  \item the first hit on the target has energy of that of the muons: 
    \begin{equation}
      \SI{3.4}{\MeV} \le E_{\textrm{target}} \le  \SI{5.6}{\MeV}
      \label{eqn:sir2_muE_cut}
    \end{equation}
\end{enumerate}
The two cuts~\eqref{eqn:sir2_prompt_cut} and~\eqref{eqn:sir2_muE_cut} give
a number of stopped muons counted by the active target:
\begin{equation}
  N_{\mu \textrm{ active Si}} = 9.32 \times 10^6
  \label{eqn:n_stopped_si_count}
\end{equation}

\subsection{Number of stopped muons from the number of X-rays}
\label{sub:number_of_stopped_muons_from_the_number_of_x_rays}
The number of nuclear captures, hence the number of stopped muons in the
active silicon target, can be inferred from the number of emitted
muonic X-rays. The reference energies and intensities of the most prominent
lines of silicon and aluminium are listed in \cref{tab:mucap_pars}.
\begin{table}[htb]
  \begin{center}
    \begin{tabular}{l l l}
      \toprule
      \textbf{Quantity} & \textbf{Aluminium} & \textbf{Silicon}\\
      \midrule 
      Muonic mean lifetime (ns) & $864 \pm 2$ & $758 \pm 2$\\
      Nuclear capture probability (\%) & $60.9 $ & $65.8$\\
      $(2p-1s)$ X-ray energy (keV) & $346.828\pm0.002$ & $400.177\pm0.005$\\
      Intensity (\%) & $79.8\pm0.8$ & $80.3\pm0.8$\\
      \bottomrule
    \end{tabular}
  \end{center}
  \caption{Reference parameters of muon capture in aluminium and silicon taken
  from Suzuki et al.~\cite{SuzukiMeasday.etal.1987} and Measday et
  al.~\cite{MeasdayStocki.etal.2007}.}
  \label{tab:mucap_pars}
\end{table}

The muonic X-rays are emitted during the cascading of the muon to the muonic 1S
state in the time scale of \SI{E-9}{\s}, so the hit caused by the X-rays must
be in coincidence with the muon hit on the active target. Therefore an
additional timing cut is applied for the germanium detector hits: 
\begin{equation}
  \lvert t_{\textrm{Ge}} - t_{\mu\textrm{ counter}} \rvert < \SI{500}{\ns}
  \label{eqn:sir2_ge_cut}
\end{equation}

The germanium spectrum after three
cuts~\eqref{eqn:sir2_prompt_cut},~\eqref{eqn:sir2_muE_cut}
and~\eqref{eqn:sir2_ge_cut} is plotted in \cref{fig:sir2_xray}. The $(2p-1s)$
line clearly showed up at \SI{400}{\keV} with very low background. A peak at
\SI{476}{\keV} is identified as the $(3p-1s)$ transition. Higher transitions
such as $(4p-1s)$, $(5p-1s)$ and $(6p-1s)$ can also be recognised at
\SI{504}{\keV}, \SI{516}{\keV} and \SI{523}{\keV}, respectively.
%The $(2p-1s)$
%line is seen at 399.5~\si{\keV}, 0.7~\si{\keV} off from the reference value of
%400.177~\si{\keV}. This discrepancy is within our detector's resolution,
%and the calculated efficiency is $(4.549 \pm 0.108)\times 10^{-5}$ -- a 0.15\%
%increasing from that of the 400.177~keV line, so no attempt for recalibration
%or correction was made.  
\begin{figure}[htb]
  \centering
    \includegraphics[width=0.85\textwidth]{figs/sir2_xray_22}
  \caption{Prompt muonic X-rays spectrum from the active silicon target.
  }
  \label{fig:sir2_xray}
\end{figure}

The net area of the $(2p-1s)$ is found to be 2929.7 by fitting a Gaussian
peak on top of a first-order polynomial from \SIrange{395}{405}{\keV}. 
Using the same procedure of correcting described in
\cref{sub:germanium_detector}, and taking detector acceptance and X-ray
intensity into account (see \cref{tab:sir2_xray_corr}), the number of muon
stopped is: 
\begin{equation}
  N_{\mu \textrm{ stopped X-ray}} = (9.16 \pm 0.28)\times 10^6,
  \label{eqn:n_stopped_xray_count}
\end{equation}
which is consistent with the number of X-rays counted using the active target.
\begin{table}[btp]
  \begin{center}
    \begin{tabular}{@{}llll@{}}
      \toprule
      \textbf{Measured X-rays}          & \textbf{Value} & \textbf{Absolute error}                                    & \textbf{Relative error}                                   \\ \midrule
      Gross integral                    & 3083           &                                                            &                                                           \\
      Background                        & 101.5          &                                                            &                                                           \\
      Net area $(2p-1s)$                & 2929.7         & 56.4                                                       & 0.02                                                      \\ 
      \vspace{0.03em}\\
      \toprule
      \textbf{Corrections} & \textbf{Value} & \multicolumn{2}{c}{\textbf{Details}}\\
      \midrule
      Random summing                    & 1.06  & \multicolumn{2}{l}{average count rate \SI{491.4}{\Hz},}\\ 
                                        &       & \multicolumn{2}{l}{pulse length \SI{57}{\us}}\\
      TRP reset                         & 1.03 & \multicolumn{2}{l}{\SI{298}{\s} loss during \SI{9327}{\s} run period}\\
      Self-absorption                   & 1.008 & \multicolumn{2}{l}{silicon thickness \SI{750}{\um},}\\ 
                                        &       & \multicolumn{2}{l}{linear attenuation \SI{0.224}{\per\cm}}\\
      True coincidence                  & 1              & \multicolumn{2}{l}{omitted}                                                                                            \\ 
      \vspace{0.03em}\\
      \toprule
      \textbf{Efficiency and intensity} & \textbf{Value} & \textbf{Absolute error}                                    & \textbf{Relative error}                                   \\
      \midrule
      Detector efficiency               & \num{4.40E-4}        & \num{0.978E-5}                                                   & 0.02                                                     \\
      X-ray intensity                   & 0.803          & 0.008                                                      & 0.009                                                     \\ 
      \vspace{0.03em}\\
      \toprule
      \textbf{Results}                  & \textbf{Value} & \textbf{Absolute error}                                    & \textbf{Relative error}                                   \\
      \midrule
      Number of X-rays emitted          & \num{7.36E6}         & \num{0.22E6}                                                     & 0.03                                                      \\
      Number of muons stopped           & \num{9.16E6}         & \num{0.28E6}                                                     & 0.03                                                      \\
      \bottomrule
    \end{tabular}
  \end{center}
  \caption{Corrections, efficiency and intensity used in calculating the number
    of X-rays from the active target.} 
  \label{tab:sir2_xray_corr}
\end{table}

%In order to measure the charged particles after nuclear muon capture, one would
%pick events where the emitted particles are well separated from the
%muon stop time. The energy timing correlation plot suggests a timing window
%starting from at least 1200~ns, therefore another cut is introduced:
%\begin{enumerate}
    %\setcounter{enumi}{2}
  %\item there are at least two hits on the active target, the time
    %difference between the second hit on target (decay or capture product) and
    %the muon counter hit is at least 1300 ns:
    %\begin{equation}
      %t_{\textrm{target 2nd hit}} - t_{\mu\textrm{ counter}} \geq \SI{1300}{\ns}
      %\label{eqn:sir2_2ndhit_cut}
    %\end{equation}
%\end{enumerate}

%The three cuts~\eqref{eqn:sir2_prompt_cut},~\eqref{eqn:sir2_muE_cut} and
%~\eqref{eqn:sir2_2ndhit_cut} reduce the sample to the size of \num{9.82E+5}.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Particle identification by specific energy loss}
\label{sec:particle_identification_by_specific_energy_loss}
In this analysis, a subset of runs from \numrange{2808}{2873} with  the
100-\si{\um} aluminium target is used because of following advantages:
\begin{itemize}
  \item it was easier to stop and adjust the muon stopping distribution in
    this thicker target;
  \item a thicker target means more stopped muons due to higher muon rate
    available at higher momentum and less scattering.
\end{itemize}
Muons momentum of \SI{30.52}{\MeV\per\cc}, 3\%-FWHM spread (scaling factor of
1.09, normalised to \SI{28}{\MeV\per\cc}) were used for this target after
a momentum scanning as described in the next subsection.

\subsection{Momentum scan for the 100-\si{\um} aluminium target}
\label{sub:momentum_scan_for_the_100_}
Before deciding to use the momentum scaling factor of 1.09, we have scanned
with momentum scales ranging from 1.04 to 1.12 to maximise the 
observed X-rays rate(and hence maximising the rate of stopped muons). The X-ray
spectrum at each momentum point was accumulated in more than 30 minutes to 
assure a sufficient amount of counts. Details of the scanning runs are listed
in \cref{tab:al100_scan}.
\begin{table}[htb]
  \begin{center}
    \begin{tabular}{cccc}
      \toprule
      \textbf{Momentum (\si{\MeV\per\cc})} & \textbf{Scaling factor} & \textbf{Runs}
      & \textbf{Length (s)}\\
      \midrule 
      29.12 & 1.04 & \numrange{2609}{2613} &2299\\
      29.68 & 1.06 & \numrange{2602}{2608} &2563\\
      29.96 & 1.07 & \numrange{2633}{2637} &2030\\
      30.24 & 1.08 & \numrange{2614}{2621} &3232\\
      30.52 & 1.09 & \numrange{2808}{2813} &2120\\
      30.80 & 1.10 & \numrange{2625}{2632} &3234\\
      31.36 & 1.12 & \numrange{2784}{2792} &2841\\
      \bottomrule
    \end{tabular}
  \end{center}
  \caption{Momentum scanning runs for the 100-\si{\um} aluminium target.}
  \label{tab:al100_scan}
\end{table}
The on-site quick analysis suggested the 1.09 scaling factor was the
optimal value so it was chosen for all the runs on this aluminium target. But
the offline analysis later showed that the actual optimal factor was 1.08.
There were two reasons for the mistake:
\begin{enumerate}
  \item the X-ray rates were normalised to run length, which is biased
    since there are more muons available at higher momentum;
  \item the $(2p-1s)$ peaks of aluminium at \SI{346.828}{\keV} were not
    fitted properly. The peak is interfered by a background peak at
    \SI{351}{\keV} from $^{214}$Pb, but the X-ray peak area was
    obtained simply by subtracting an automatically estimated background.
\end{enumerate}
In the offline analysis, the X-ray peak and the background peak are fitted by
two Gaussian peaks on top of a first-order polynomial background. The X-ray peak
area is then normalised to the number of muons hitting the upstream detector
(\cref{fig:al100_xray_fit}).
\begin{figure}[htb]
  \centering
    \includegraphics[width=0.47\textwidth]{figs/al100_xray_fit}
    \includegraphics[width=0.47\textwidth]{figs/al100_xray_musc}
  \caption{Fitting of the $(2p-1s)$ muonic X-ray of aluminium and the background
    peak at \SI{351}{\keV} (left). The number of muons is integral of the
    upstream scintillator spectrum (right) from \numrange{400}{2000} ADC
    channels.} 
  \label{fig:al100_xray_fit}
\end{figure}
The ratio between the number of X-rays and the number of muons as a function
of momentum scaling factor is plotted on \cref{fig:al100_scan_rate}. The trend
showed that muons penetrated deeper as the momentum increased, reaching the
optimal value at the scale of 1.08, then decreased as punch through happened
more often from 1.09. The distributions of stopped muons are illustrated by
MC results on the right hand side of \cref{fig:al100_scan_rate}. With the 1.09
scale beam, the muons stopped \SI{28}{\um} off-centre to the right silicon arm.
\begin{figure}[htb]
  \centering
    \includegraphics[width=0.47\textwidth]{figs/al100_scan_rate}
    \includegraphics[width=0.47\textwidth]{figs/al100_mu_stop_mc}
  \caption{Number of X-rays per incoming muon as a function of momentum
    scaling factor (left); and muon stopping distributions from MC simulation
    (right). The depth of muons is measured normal to surface of the target
    facing the muon beam.}
  \label{fig:al100_scan_rate}
\end{figure}

\subsection{Event selection for the passive targets}
\label{sub:event_selection_for_the_passive_targets}
As described in the \cref{sec:analysis_framework}, the hits on all detectors
are re-organised into muon events: central muons; and all hits within
\SI{\pm 10}{\us} from the central muons. The dataset from runs
\numrange{2808}{2873} contains \num{1.17E+9} such muon events.

Selection of proton (and other heavy charged particles) events starts from
searching for muon event that has at least one hit on thick silicon. If there
is a thin silicon hit within a coincidence window of $\pm 0.5$~\si{\us}\ around
the thick silicon hit, the two hits are considered to belong to one particle.
The specific energy loss spectra recorded by the two silicon arms are plotted
on \cref{fig:al100_dedx}.
\begin{figure}[htb]
  \centering
    \includegraphics[width=0.85\textwidth]{figs/al100_dedx}
  \caption{Energy loss in thin silicon detectors as a function of total energy
    recorded by both thin and thick detectors.}
  \label{fig:al100_dedx}
\end{figure}
With the aid from MC study (\cref{fig:pid_sim}), the banding on
\cref{fig:al100_dedx} can be identified as follows: 
\begin{itemize}
  \item the densest spot at the lower left conner belonged to electron hits; 
  \item the small blurry cloud just above the electron region was muon hits;
  \item the most intense band was due to proton hits; 
  \item the less intense, upper band caused by deuteron hits; 
  \item the highest band corresponded to alpha hits; 
  \item the faint stripe above the deuteron band should be triton
    hits, which is consistent with a relatively low probability of emission of
    tritons.  
\end{itemize}

The band of protons is then extracted by cut on likelihood probability
calculated as:
\begin{equation}
  p_{i} = \dfrac{1}{\sqrt{2\pi}\sigma_{\Delta E}}
  e^{\frac{(\Delta E_{meas.} - \Delta E_i)^2} {2\sigma^2_{\Delta E}}}
\end{equation}
where $\Delta E_{\textrm{meas.}}$ is measured energy deposition in the thin
silicon detector by a certain  proton at energy $E_i$, $\Delta E_i$  and
$\sigma_{\Delta E}$ are the expected and standard deviation of the energy loss
caused by the proton calculated by MC. A cut value of $3\sigma_{\Delta E}$, or
$p_i \ge 0.011$,  was used to extract protons (\cref{fig:al100_protons}).
\begin{figure}[htb]
  \centering
    \includegraphics[width=0.47\textwidth]{figs/al100_protons}
    \includegraphics[width=0.47\textwidth]{figs/al100_protons_px_r}
  \caption{Protons (green) selected using the likelihood probability cut
    (left). The proton spectrum (right) is obtained by projecting the proton
    band onto the total energy axis.}
  \label{fig:al100_protons}
\end{figure}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Proton emission rate from aluminium}
\label{sec:proton_emission_rate_from_aluminium}
The analysis is done on the same dataset used in
\cref{sec:particle_identification_by_specific_energy_loss}. Firstly, the
number of protons emitted is extracted using specific energy loss. Then
correction for energy loss inside the target is applied. Finally, the number
of protons is normalised to the number of nuclear muon captures.

\subsection{Number of protons emitted}
\label{sub:number_of_protons_emitted}
From the particle identification above, number of protons having energy in the
range from \SIrange{2.2}{8.5}{\MeV} hitting the two arms are:
\begin{align}
  N_{\textrm{p meas. left}} = 1822 \pm 42.7\\
  N_{\textrm{p meas. right}} = 2373 \pm 48.7
\end{align}
The right arm received significantly more protons than the left arm did, which
is expected as in \cref{sub:momentum_scan_for_the_100_} it is shown that
muons stopped off centre to the right arm.

%%TODO
The uncertainties are statistical only. The systematic uncertainties due to
the cut on protons is estimated to be small compared to the statistical ones.

\subsection{Corrections for the number of protons}
\label{sub:corrections_for_the_number_of_protons}
The protons spectra observed by the silicon detectors have been modified by
the energy loss inside the target so correction (or unfolding) is necessary.
The unfolding, essentially, is finding a response function that relates proton's
true energy and measured value. This can be done in MC simulation by generating
protons with a spatial distribution as close as possible to the real
distribution of muons inside the target, then counting the number of protons
reaching the silicon detectors. Such response function conveniently includes
the geometrical acceptance.

For the 100-\si{\um} aluminium target and muons at the momentum scale of 1.09,
the parameters of the initial protons are:
\begin{itemize}
  \item horizontal distribution: Gaussian \SI{26}{\mm} FWHM, centred at the
    centre of the target;
  \item vertical distribution: Gaussian \SI{15}{\mm} FWHM, centred at the
    centre of the target;
  \item depth: Gaussian \SI{69.2}{\um} FWHM, centred at \SI{68.8}{\um}-deep from
    the upstream face of the target;
  \item energy: flatly distributed from \SIrange{1.5}{15}{\MeV}.
\end{itemize}
The resulting response matrices for the two arms are presented in
\cref{fig:al100_resp_matrices}. These are then used as MC truth to train  and
test the unfolding code. The code uses an existing ROOT package
called RooUnfold~\cite{Adye.2011} where the iterative Bayesian unfolding
method is implemented.
\begin{figure}[htb]
  \centering
  \includegraphics[width=0.85\textwidth]{./figs/al100_resp}
  \caption{Response functions for the two silicon arms.}
  \label{fig:al100_resp_matrices}
\end{figure}
After training the unfolding code is applied on the measured spectra from the
left and right arms. The unfolded proton spectra 
