\T\T\T In order to achieve background rejection while preserving as much signal as possible, we must look for a set of variables whose distribution allows to separate $K^+ \rightarrow \pi^+ \nu \bar{\nu}$ events from the target background $K^+ \rightarrow \pi^+ \pi^0$. We may then set appropriate cuts on these distributions, and transmit to higher trigger levels only the portion of data fulfilling these requirements.\\



\section{$\boldsymbol{{\beta_{\pi} - \theta_{K\pi}}}$ correlation}

In \chaptername~\ref{ch:2body} I outlined the kinematics of the $K^+ \rightarrow \pi^+ \pi^0$ decay and introduced Eqn.~\ref{eqn:thetabeta}, that could be used to identify this background. The $K^+ \rightarrow \pi^+ \nu \bar{\nu}$ decay is a 3-body process, and therefore its kinematics is not constrained. Background rejection could be obtained by determining ${\left(\theta_{K\pi}\right)}_{2-body}$ as a function of the RICH-measured $\beta_\pi$ for each event, and discarding those events whose reconstructed $\theta_{K\pi}$, computed from the direction $\theta_\pi$ detected at the RICH, is close to ${\left(\theta_{K\pi}\right)}_{2-body}$.\\

\begin{figure}
\centering
\subfigure[]{\includegraphics[width=\textwidth]{Images/pdf/L0algo/thetabetanosignalcuts}\label{img:rad-rc:1}}
\vfill
\subfigure[]{\includegraphics[width=\textwidth]{Images/pdf/L0algo/rad_vs_rc_aggiustato}\label{img:rad-rc:2}}
\caption{Top plot \textbf{(a)}: the distributions of the signal and of the $\pi^+\pi^0$ background in the ${\left(\theta_{K\pi}\right)}_{2-body} - \beta_\pi$ plane. Bottom plot \textbf{(b)}: the same plane is remapped to the raw \v{C}erenkov ring observables, and L0 trigger and standard signal cuts (see \tablename~\ref{tb:sigdef}) are applied to the data sets.}\label{img:rad-rc}
\end{figure}

Unfortunately, the Montecarlo simulations I will report in this chapter have revealed that the resolution of the RICH is not sufficient to successfully exploit this approach. In \figurename~\ref{img:rad-rc:1}, the black dots corresponds to the exact mathematical relation between the decay angle and the velocity of the pion for the $K^+ \rightarrow \pi^+ \pi^0$ decay, described in Eqn.~\ref{eqn:thetabeta}. The red dots correspond to RICH-reconstructed $ \left( \beta_\pi ,  \theta_{K\pi} \right) $ pairs, computed as described in \chaptername~\ref{ch:reco}, for simulated $\pi^+\pi^0$ events, while blue dots represent simulated $\pi^+ \nu \bar{\nu}$ events.\\
%The red dots correspond to values of $\theta_{K\pi}$ computed using RICH-reconstructed values of $\beta_\pi$ for simulated $\pi^+\pi^0$ events, while blue dots correspond to simulated $\pi^+ \nu \bar{\nu}$ events.\\

It can be inferred from \figurename~\ref{img:rad-rc:1} that:
\begin{itemize}
\item $\pi^+\pi^0$ events (red dots) cover a wide area of the ${\left(\theta_{K\pi}\right)}_{2-body} - \beta_\pi$ plane, and there is a slight asymmetry compared to the expected occupancy (black dots); this means that the resolution of a single detector might not be sufficient to perform such bi-dimensional selection.
\item The regions occupied by the two data sets -- signal (blue) and $\pi^+\pi^0$ background (red) -- completely overlap.
\end{itemize}
It follows that a significant bi-dimensional cut set up on relation~\ref{eqn:thetabeta} would reject a large amount of signal events, and therefore it is not feasible.\\

\figurename~\ref{img:rad-rc:2} is a re-parametrisation of the plot shown in \ref{img:rad-rc:1}. Here, the radius and position of the \v{C}erenkov ring are put in the relation emerging from Eqn.~\ref{eqn:thetabeta}:
\begin{align}
&d(r_c) = d \left( \theta \left( \beta \left( r_c \right) \right)\right)
\end{align}
where $d(\theta)$ is the ring centre distance to the focus, defined in Eqn.~\ref{eqn:d-theta}, $\theta (\beta)$ was defined in Eqn.~\ref{eqn:thetabeta}, $\beta ( r_c)$ in Eqns.~\ref{eqn:rc-thetac} and~\ref{eqn:beta-thetac} and $r_c$ is the \v{C}erenkov ring radius. The aim of this test was to understand if the spread of the distributions of \figurename~\ref{img:rad-rc:1} was due to the intrinsic resolution of the RICH detector or if it was a consequence of computational issues arising during the evaluation of $\beta_\pi$ and $\theta_{K\pi}$. From \figurename~\ref{img:rad-rc:2} we see that such spread is due to the finite resolution of the RICH, and unfortunately this issue cannot be overcome in the contest of a real-time trigger.
Moreover, the signal selection and standard L0 trigger cuts applied in this plot have the effect of thinning the area covered by $\pi\nu\bar{\nu}$ data, thus making a bi-dimensional selection of $\pi^+\pi^0$ unattainable.



\section{Missing mass}
In principle, what best distinguishes a 3-body from a 2-body decay is the energy spectrum of the decay products. In a 2-body decay, the energy spectrum of the $\pi^+$ in the rest frame of the decaying kaon is single-valued (see \chaptername~\ref{ch:2body}).\\
 
Instead, for a 3-body decay (such as the signal) the rest frame energy of the $\pi^+$ belongs to a continuum that spreads roughly from $m_K - m_{\pi}$ to as near to zero as our detectors can measure (the mass of the neutrinos is negligible with respect to the precision of these instruments). \figurename~\ref{img:m2miss_regions} shows the shapes of the squared missing mass to the detected pair $\left(K^+, \; \pi^+\right)$ for the target process and the most important $K^+$ decay modes.\\
%, defined as\\
%\begin{align}
%&M^2_{\rm miss} = {\left( P^{\mu}_K - P^{\mu}_{\pi} \right)}^2
%\end{align}
%
%\begin{figure}
%\centering
%\includegraphics[width=0.8\textwidth]{Images/pdf/trigIntro/mmiss}
%\caption{Spectrum of the missing mass to the detector $K^+$ and $\pi^+$ for the sought process and its major backgrounds\\
%C'E' GIA' UNA FIGURA UGUALE}\label{img:mmiss-theor}
%\end{figure}

For the two-body decay this quantity is theoretically expected to distribute as a Dirac delta centred in $m_{\pi^0}^2 \simeq 0.0182$ \si{\giga\electronvolt^2/\textit{c}^4}. Taking the finite resolution of our detectors into account, we expect a Gaussian distribution around this value.\\

%However, the RICH detector was not designed to give such a precise kinematic measurement: therefore, this path may not lead to a good separation of the two processes. 
I explored the possibility of using the missing mass, computed using exclusively the information originating from the RICH detector, as a cut variable.
However, as shown in \figurename~\ref{img:mmiss-rich}, due to the limited momentum resolution of the RICH it is not possible to separate the two processes this way either.
In fact, the two sets of simulated events (respectively signal and $\pi^+\pi^0$ background) end up in wide superposition on this variable.\\ %\chaptername~\ref{ch:reco} explains the steps I took to achieve a proper reconstruction of the momentum and flight direction of the pions.\\

\begin{figure}
\centering
\includegraphics[width=\textwidth]{Images/pdf/trigIntro/mmiss_rich}
\caption{Spectrum of the missing mass to the $K^+$ and $\pi^+$ for the signal and the $K^+ \rightarrow \pi^+ \pi^0$ background. The missing mass was computed using the information from the rings detected on the RICH, assuming that the particle crossing the detector was a $\pi^+$. These spectra were obtained from the superposition of two sets of simulated events, one containing only $K^+ \rightarrow \pi^+ \nu \bar{\nu}$ and one only $K^+ \rightarrow \pi^+ \pi^0$ decays.}\label{img:mmiss-rich}
\end{figure}

At the final level of data analysis, NA62 expects to put strong contraints on the events to be tagged as \textbf{signal}. These should be set as follows:
\begin{itemize}
\item $15 \leq P_{\pi} \leq 35$ \si{\giga\electronvolt/\textit{c}}, i.e. the range of momenta for which the $\mu$--$\pi$ separation achieved is maximum ($P_\pi \geq 15 $ \si{\giga\electronvolt/\textit{c}}), with an upper limit that ensures that the other particles from $K^+$ decay carry a momentum of at least 40~\si{\giga\electronvolt/\textit{c}} and are therefore detectable. This way, for example, at least one photon from $\pi^0 \rightarrow \gamma \gamma$ decay is bound to fall in the acceptance of the NA62 detector.%(with the pion emitted backwards in the centre-of-mass frame). This way, for example, at least one photon from $\pi^0$ decay is bound to fall in the acceptance of the NA62 detector;
\item $105 \leq z_{\rm vtx} \leq 165$ \si{\meter}, where $z_{\rm vtx}$ is the $z$ coordinate of the decay vertex, i.e. the $K^+$ decay happened in the fiducial region.
\item $m^2_{\rm miss} \in R_1 = (0, 0.01) $ or $\in R_2 = (0.026, 0.068)$ \si{\giga\electronvolt\tothe{2}/\textit{c}\tothe{4}}, in order to explore only ``background-free'' regions (see \figurename~\ref{img:m2miss_regions}).
\end{itemize}

Events not fulfilling these requirements will be left out of the fiducial sample for data analysis.
Such events would be discarded in any case at a later stage, but we may exploit the signal selection to reject them already at the online L0 stage. This will obviously reduce the amount of data fed to higher level triggers, thus allowing more efficient evaluations at those stages.\\



\section{\v{C}erenkov ring radius}
First of all, we notice that the signal is distributed along a limited range of momenta, 15 to 35 \si{\giga\electronvolt/\textit{c}}.
%For first thing we notice that the signal is selected in momentum. 
This means that the velocity of a charged particle should be in a range defined by its mass, in order for the particle not to be discarded. In the RICH detector, this results in limits to the radius of the \v{C}erenkov rings. 
A Montecarlo simulation performed with the NA62 software allowed me to find the distributions of the radius of the \v{C}erenkov rings for signal and background events. The results are shown in \figurename~\ref{img:ringrad-rich}, where we can see that this quantity provides a good option for events separation.\\

\begin{figure}
\centering
\includegraphics[width=\textwidth]{Images/pdf/trigIntro/ring_radius}
\caption{Reconstructed \v{C}erenkov ring radius for the signal and the $K^+ \rightarrow \pi^+ \pi^0$ background after L0 cuts have been applied (Montecarlo-simulated data).}\label{img:ringrad-rich}
\end{figure}

In particular, we can see that the peak value of the \v{C}erenkov radius is on average larger for $\pi^+ \pi^0$ events than it is for $K^+ \rightarrow \pi^+ \nu \bar{\nu}$ events.\\

If the signal had not been momentum-selected, we would have expected the peak of $\pi^+ \pi^0$ events to be lower than that of the signal, due to the different kinematics of the two processes. In the two-body decay, the charged and neutral pion masses are similar, and therefore they carry similar fractions of the kaon energy, about 50\% each in the rest frame of the kaon. On the other hand, the sought 3-body decay with two neutrinos contains only one pion, and it is the only particle with a mass of the same order of magnitude as that of the kaon. In this case, the larger fraction of the kaon energy is statistically carried by the pion, and smaller fractions contribute energy to the neutrinos. As a consequence, in the $K^+ \rightarrow \pi^+ \nu \bar{\nu}$ decay the $\pi^+$ is on average faster than when originating from $K^+ \rightarrow \pi^+ \pi^0$ events. A higher velocity $\beta$ produces larger circles on the focal plane of the RICH detector, as shown in \figurename~\ref{img:rich-rc}.\\

\begin{figure}
\centering
\includegraphics[width=\textwidth]{Images/pdf/trigIntro/rc}
\caption{Expected radius of the \v{C}erenkov ring for a range of velocities from $\beta = 1/n$ to $\beta = 1$. In this study I used $f = 17$~\si{\meter} and $n = 1.0000613422636$, the design values of the RICH detector for NA62.}\label{img:rich-rc}
\end{figure}

However, the fiducial momentum region defined for the signal allows us to discard a priori those events where the detected pion has a momentum greater than 35~\si{\giga\electronvolt/\textit{c}}. This way, as \figurename~\ref{img:ringrad-rich} suggests, we can suppress a major component of the $\pi^+\pi^0$ background.

%\section{\v{C}erenkov ring $\chi^2$}
%When I started working on this thesis, there were no multi-ring parallel fitting algorithms in literature ready to be adapted to RICH applications. For this reason, I tried to figure out how to discard events with more than one ring, that are not relevant at all for the experiment.\\
%
%If there are only single-ring algorithms available, the easiest way to check whether the data points really belong to a single circle is to perform a $\chi^2$ analysis on the ring cadidate. Except in the rare case when two rings are concentric and similar in radius, a \textit{least squares} analysis will return a higher $\chi^2$ when the points do not belong to the same ring.\\
%
%The studied background process $K^+ \rightarrow \pi^+ \pi^0$ may create multiple rings in case of:
%\begin{itemize}
%\item inelastic scattering on the material of upstream detectors (these events would be rejected at an offline level anyway)
%\item Dalitz $\pi^0$ decay: $\pi^0 \rightarrow e^+ e^- \gamma$
%\item pair production in a far upstream region
%\end{itemize}
%
%According to the results presented in the next sections, a threshold $\chi^2_{\rm max} = 1$ improves the global $\pi^+ \pi^0$ rejection by a small percentage.\\
%
%QUESTI RISULTATI ANCORA NON LI HO MESSI



\section{Other possible optimizations}\label{sect:more-rej-delta}
As discussed in Section~\ref{sect:rich}, the RICH detector not only allows to perform particle identification by distinguishing between muons and pions: it also provides information about the flight direction of the charged particle crossing its volume. \figurename~\ref{img:mmiss-rich} shows that it is inefficient to use the missing mass as a discriminating variable, with the resolution available online.
%tells us that the way of the missing mass as a discriminating variable is unfeasible with the resolution we achieve at a stage of online triggering.
However, there may be some other variables which could exploit the whole information we get from both the detection and our understanding of the decay process responsible for $\pi^+ \pi^0$ events. Herein I will show how to look for such variables and to exploit them. The results achieved so far have only provided marginal improvements to the background rejection level already obtained. This approach necessarily involves mathematical difficulties; nevertheless, even a numerical approximation, if found, could provide interesting results in the future.\\

In the two-body decay scenario,
% the main problem with the missing mass is 
the correlation between the ring radius and the position of its centre, that reflects the one existing between the momentum and angle of the $\pi^+$ (see \chaptername~\ref{ch:2body}), would be a valuable way to separate signal from background. However, 
%unfortunately -- as shown by the unconclusive results of my analysis of the missing mass approach (\figurename~\ref{img:mmiss-rich}) -- 
it also causes difficult computational issues. In fact, the variance is greater for a function of two correlated variables than it is for a function of uncorrelated variables. Such variance can be computed according to the general error propagation formula.\\

Given a set $\vec{x}$ of $n$ random variables with expectation values $\vec{\mu}$, and a function $f(\vec{x})$, assuming we can perform a Taylor expansion around $\vec{\mu}$:
\begin{align}
&f(\vec{x}) = f(\vec{\mu}) + \sum_{i=1}^{n} (x_i - \mu_i) \frac{\partial f}{\partial x_i}\bigg|_{\vec{x}=\vec{\mu}} + \dots
\end{align}
Truncating at first order:
\begin{align}
\E(f) =& f(\vec{\mu}) + \dots\\
\Var(f) =& \E \left( {\left(f - \E(f) \right)}^2 \right)\\
 =& \E \left( {\left( f(\vec{x}) - f(\vec{\mu}) \right)}^2 \right)\\
 \simeq& \sum_{i=1}^{n} \sum_{j=1}^{n} \left( \frac{\partial f}{\partial x_i}\frac{\partial f}{\partial x_j}\bigg|_{\vec{x}=\vec{\mu}} \right) \Var_{ij} (\vec{x})
\end{align}
For a function $f$ of two variables $x$ and $y$:
\begin{align}
\Var(f) = \sigma^2_x \, {\left(\frac{\partial f}{\partial x}\bigg|_{\vec{x}=\vec{\mu}}\right)}^2
+ \sigma^2_y \, {\left(\frac{\partial f}{\partial y}\bigg|_{\vec{x}=\vec{\mu}}\right)}^2
+ 2 \, \Cov (x,y) \left( \frac{\partial f}{\partial x}\frac{\partial f}{\partial y}\bigg|_{\vec{x}=\vec{\mu}} \right)
\end{align}
%The covariance matrix $\Var_{ij}(\vec{x})$ is known. To minimize a functional ($\Var(f)$) is a variational problem without a general solution.
%
%\begin{align}
%&\Var [f(\vec{x})] = {\left(\frac{\partial^2 f}{\partial x_i \partial x_j}\right)}_{\vec{x} = \E (\vec{x})} \Var_{ij} (\vec{x})
%\end{align}
%where the vector $\vec{x}$ represents the input random variables and $\Var_{ij}$ are the elements of the associated covariance matrix, that is only diagonal if there is no correlation between the $x_i$.\\

In the case of the missing mass, the small RMSs in the reconstructed kinematic variables $\beta_\pi$ and $\theta_{K\pi}$ add up in a nonlinear way, thus making it an unconvenient statistical variable from a computational point of view.\\

The RICH reconstruction algorithm as it is now implemented exhibits a slight asymmetry in the reconstruction of the particle velocity $\beta$, which is usually overestimated (as shown in \figurename~\ref{img:reco-res} in \chaptername~\ref{app:rich_res}).
This results in an inaccurate estimate of the particle flight direction, through the assessment of its momentum $P(\beta, m_{\pi})$ and the backwards propagation of the track across the two upstream magnets (see \chaptername~\ref{ch:reco}). In particular, the magnitude of the magnetic deflection due to the spectrometer magnet is inversely proportional to the momentum of the particle.
The correlated deviations of the reconstructed position and radius of the \v{C}erenkov rings therefore add up when used to compute functions $f(\beta_{\pi},\theta_{K\pi})$ of both variables, e.g. the function evaluating the missing mass $m^2_{\rm miss}(K^+,\pi^+)$.\\

The problem of finding the function $g(\beta_{\pi},\theta_{K\pi})$ that makes use of as much information as possible while keeping its variance low is very interesting from a mathematical point of view. Minimizing a functional ($\Var(f)$ in this case) is a variational problem without a general solution. Unfortunately, our knowledge is limited to the covariance matrix of the two variables, and this does not allow for an algebraic solution to this problem. Moreover, in the 2-body decay $\beta_{\pi}$ and $\theta_{K\pi}$ are not only strongly correlated, but also functionally dependent.
Therefore, the only reasonable solution would be a variable obtained with as few computation steps as possible, but containing full information about the physical process: for example
% with a limited content of calculus but full information about the physical process: for example,
\begin{align}
&\delta \equiv \theta_{K\pi} - \theta_{K\pi}(\beta_{\pi})\label{eqn:delta}
\end{align}
would exploit the functional relation between $\theta_{K\pi}$ and $\beta_{\pi}$ in the $K^+ \rightarrow \pi^+ \pi^0$ decay, while preventing further computational steps that might increase the variance of the test variable.\\

%We expect 
It is expected that the distribution of $\delta$ for $\pi^+ \pi^0$ events is peaked at 0. On the other hand, nothing can be said a priori about the distribution of $\delta$ for events $\pi^+ \nu \bar{\nu}$, which do not feature such functional dependence. The width of the distribution for background events might be small enough to allow a cut in a short range around 0.\\

\begin{figure}
\centering
\includegraphics[width=\textwidth]{Images/pdf/trigIntro/thetamenotheta_bgL0sigL0}
\caption{Distribution of $\delta$ defined in Eqn.~\ref{eqn:delta} for signal and background events sets.}\label{img:delta}
\end{figure}
Unfortunately, this is not a completely acceptable solution either, as shown by the simulation results reported in \figurename~\ref{img:delta}.
The distribution in $\delta$ for the signal events, in fact, is very narrow and centred so close to 0 that it almost completely overlaps the peak arising from $\pi^+ \pi^0$ events. Furthermore, the signal lies in the momentum range for which the RICH provides maximum accuracy in the reconstruction of $\beta$; since this is not true for the background, an asymmetry arises in the reconstruction of $\beta$, that spreads the corresponding distribution towards the positive side.\\

However, we may once more exploit the fact that the background is not filtered according to the pion momentum, and remove those events for which the reconstruction asymmetry exceeds a given threshold from the data pool, for example by requiring $\delta \leq 0.002$ at trigger level.\\
%
%DIRE PERCENTUALE RIGETTO IN QUESTO MODO