%==========================================
%
%   Appendices related to the selection 
%
%==========================================

\section{Event selection}

\subsection{Crystal Ball function}\label{app:CrystalBall}

The Crystal Ball function is a probability density function widely used to model processes with losses \cite{APP-CB}.
 It consists of a gaussian core and one power-law low end tail, that describes the loss, typically from the final state radiation. The function got its name from the Crystal Ball collaboration \cite{APP-CBCollab}. 
The experiment was placed at the SPEAR accelerator at SLAC National Laboratory and designed as a spark chamber surrounded by an almost complete sphere (covering 98\% of the solid angle) made of scintillating crystals. Therefore, the detector got its prophetic name. The detector is operating until today. 
It is located in Mainz, placed at the MAMI microtron \cite{APP-CBMainz}.

The Crystal Ball function is then defined as
\begin{equation}
  \mathcal{P}(x;\alpha,n,\bar x,\sigma) = N \cdot
  \begin{cases} 
	 \exp(- \frac{(x - \bar x)^2}{2 \sigma^2}), & \mbox{for }\frac{x - \bar x}{\sigma} > -\alpha \\
	 A \cdot (B - \frac{x - \bar x}{\sigma})^{-n} & \mbox{for }\frac{x - \bar x}{\sigma} \leqslant -\alpha 
  \end{cases}\,,
\end{equation}
where $A$ and  $\alpha$ and $n$ describe the tail, $\mu$ and $\sigma$ are the mean and the width of the peak. $N$ is a normalization factor, $A$ and $B$ are constants defined as:
\begin{align}
\begin{split}
A &= \left(\frac{n}{\left| \alpha \right|}\right)^n \cdot \exp\left(- \frac {\left| \alpha \right|^2}{2}\right)\,,\\
B &= \frac{n}{\left| \alpha \right|}  - \left| \alpha \right|\,.\\
%N &= \frac{1}{\sigma (C + D)}\,,\\
%C &= \frac{n}{\left| \alpha \right|} \cdot \frac{1}{n-1} \cdot \exp\left(- \frac {\left| \alpha \right|^2}{2}\right)\,,\\
%D &= \sqrt{\frac{\pi}{2}} \left(1 + \operatorname{erf}\left(\frac{\left| \alpha \right|}{\sqrt 2}\right)\right)\,.
\end{split}
\end{align}
%
%The $\operatorname{erf}$ is Gauss error function defined as
%
%\begin{equation}
%	erf(z) =\frac{2}{\sqrt\pi}\int_0^z e^{-t^2}\,dt\,.
%\end{equation}

\subsubsection{Double sided Crystal Ball function}

The Crystal Ball function can be extended to contain  a gaussian core and two power-law low end tails.
The double sided Crystal Ball function is then defined as 
%
\begin{align}
\mathcal{P}_{CB}(x; x_{peak}, \sigma, n_1, n_2, \alpha_1, \alpha_2) = N \cdot
\begin{cases}
A_1\cdot(B_1 - \frac{x-x_{peak}}{\sigma})^{-n_1} & $for $  \frac{x - x_{peak}}{\sigma} \leq -\alpha_1
\vspace*{0.3cm}\\ 
\exp(\frac{-(x - x_{peak})^{2}}{2\sigma^{2}})	 & $for $ -\alpha_1 \leq \frac{x - x_{peak}}{\sigma} \leq \alpha_2
\vspace*{0.3cm}\\      
A_2\cdot(B_2 - \frac{x-x_{peak}}{\sigma})^{-n_2} & $for $ \alpha_2 \leq \frac{x - x_{peak}}{\sigma} 
\end{cases} 
\,,
\end{align}
%
$N$ is a normalization factor,  $A_{1,2}$ and $B_{1,2}$ are constants defined as:
\begin{align}
\begin{split}
A_{1,2}=		& ( \frac{n_{1,2}}{\abs{n_{1,2}}} )^{n_{1,2}} \cdot \exp(\pm\frac{\alpha_{1,2}^{2}}{2}), 
\vspace*{0.3cm}\\      
B_{1,2}=		& \frac{n_{1,2}}{\abs{\alpha_{1,2}}} - \abs{\alpha_{1,2}}.
\end{split}
\end{align} 



\subsection{ExpGaus function}\label{app:ExpGaus}

ExpGaus function is a function used to describe partially reconstructed backgrounds in \B~meson decays. The definition is in \refEq{App-ExpGaus}. The $\mu$ denotes the mean of the distribution, $\sigma$ is the variance of the function, D is a constant representing the decay of the B meson.
%
\begin{align}\label{eq:App-ExpGaus}
f_{EG}(x) = 
\begin{cases}
\exp\left(-\frac{\mu-D}{\sigma^2} \left(x-D\right)\right) \exp\left(-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2\right) & \text{if } x \leq D\\
\exp\left(-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2\right)              & \text{otherwise}
\end{cases}
\,.
\end{align} 

%\clearpage


%\subsection{Correction to the simulation}\label{app:SimulationCorrection}
%\todo[inline]{\piz pseudorapidity resolution: data does not agree with MC, see talk from 2018\_05\_14}
%
%\clearpage

\subsection{Reweighted distributions of parameters used for the MLP training}\label{app:CompareVariables}

\input{./figures/fig_CompareVariables}
%\input{./figures/fig_CompareVariables_sig}

%\clearpage

%\subsection{\lone trigger efficiency}\label{app:L0Eff}
%\input{Chapters/EventSelection/L0Efficiency}
%
\clearpage

\subsection[Signal yield in bins of the dimuon invariant mass squared]{Signal yield in bins of the dimuon invariant mass squared}\label{app:yield_q2}
\input{Chapters/EventSelection/FitsInQ2}

\clearpage