A convenient way must be found to initialize the process of checking the data points through the Ptolemy's theorem by providing sets of hit triplets.\\

The points assigned to each triplet should:
\begin{itemize}
\item be well separated, in order to optimize the subsequent selection of hits satisfying the Ptolemy's theorem;
\item maximise in some way the probability of belonging to the same circle, which would result in a better capability of identifying the maximum number of \v{C}erenkov rings.
\end{itemize}

%In order to maximize the efficiency of the pattern recognition step, one should try all the possible triplets of points. 
All the possible triplets of points would have to be tried in order to maximise the efficiency of the pattern recognition step. 
However, this approach is extremely time expensive and therefore not feasible at an online level within a maximum latency of 1~\si{\milli\second}. It is also unclear whether this approach would work even in an offline approach, as the amount of memory needed to store all those subsets of data could be higher than what is available on certain GPU devices. For example, for a 20-hit event, there are 1140 possible triplets. This means that, for each event, 6.84~\si{\kilo\byte} of memory are needed only to store the 16~\si{\bit} indexes of the hits forming the triplets. Supposing half of the triplets match a 20-hit ring, 1.49~\si{\giga\byte} of data would need to be stored and processed per batch of processed events (see \chaptername~\ref{app:algo-implementation}). The NVIDIA Tesla K20 GPU used for this work, that is quite a state-of-the-art device, features 5~\si{\giga\byte} of global memory in total (see \chaptername~\ref{sect:cuda}), but ``only'' 369~\si{\mega\byte} per multiprocessor, i.e. available at the same time.\\

On the other hand, the fastest approach would consist in choosing three points at random. Again, this procedure would not be optimal, as the ring-detection efficiency would be low.\\

A procedure is needed, according to which the triplets of points should be selected. 
Looking at some events from a $K^+ \rightarrow \pi^+ \pi^0$ sample, we may notice that, on a statistical basis, except for events with hits caused by noise or by particles from the beam halo, the \v{C}erenkov rings are rarely concentric or close to each other. A feasible approach may therefore consist in selecting the ``border'' hits, as there is a high chance that they belong to the same circle. \figurename~\ref{img:triplets-choice} shows two typical $\pi^+ \pi^0$ events.\\

\begin{figure}
\centering
\subfigure[One-ring event]{\includegraphics[width=0.48\textwidth]{Images/pdf/gpu_algo/1ring_noarcs}\label{img:triplets-choiche-1}}
\subfigure[Two-ring event]{\includegraphics[width=0.48\textwidth]{Images/pdf/gpu_algo/2rings_noarcs}\label{img:triplets-choiche-2}}
\subfigure[Two-ring event: pattern recognition]{\includegraphics[width=0.48\textwidth]{Images/pdf/gpu_algo/pip_ep_2arcs_green_orange_purple_yellow}\label{img:triplets-choiche-3}}
\caption{Two typical $\pi^+ \pi^0$ events as detected by the RICH subdetector. In the event represented in the top left panel, only a $\pi^+$ was detected. On the top right panel we see two rings, one of which arose from a $\pi^0$ Dalitz decay: a positron from $\pi^0 \rightarrow e^+ e^- \gamma$ was detected as well. Finally, the bottom panel demonstrates the initialization of a pattern recognition procedure. Starting from each side of the frame, the outermost three hits are selected, which undergo a condition of reciprocal distance greater than a minimum threshold. Each point can be chosen to belong to more than one ``triplet''.}\label{img:triplets-choice}
\end{figure}

We chose to select:
\begin{itemize}
\item the leftmost three points (\textit{XMIN} triplet)
\item the rightmost three points (\textit{XMAX} triplet)
\item the three points at the bottom of the frame (\textit{YMIN} triplet)
\item the three points on top of the frame (\textit{YMAX} triplet)
\end{itemize}
with the following condition on the distance $d$ between the points $\vec{t}_i$, $\vec{t}_j$ belonging to the same triplet:
\begin{align}
&d^2\left( \vec{t}_i, \vec{t}_j \right) > d^2_{th}
\end{align}
where the minimum square distance was set to $d^2_{th} = 8$ (in the rescaled units) after empirical tests: greater threshold distances do not increment the identification efficiency of ring candidates, and they increase the probability of selecting hits belonging to different \v{C}erenkov rings.\\

The choice of triplets for the two-rings event shown in \figurename~\ref{img:triplets-choiche-2} is illustrated in \figurename~\ref{img:triplets-choiche-3}.\\

The maximum number of rings that can be detected in this way is four. The NA62 experiment does not focus on the study of events with more than one charged particle, anyway. In fact, the result we need to achieve at this stage is an efficient detection of at least one circle, possibly in presence of other hits or parts of additional rings.\\

Events featuring less than 5 or more than 32 hits were discarded for this study, whose aim is in fact to strengthen the $\pi^+ \pi^0$ rejection achieved at the standard L0 trigger level. The upper limit condition may be dropped in order to develop a positive trigger for multi-particle events, such as the lepton number or lepton family number violating channels $K^+ \rightarrow \pi^- \mu^+ \mu^+$ (B.R. $< 3 \cdot 10^{-9}$) or $K^+ \rightarrow \pi^+ \mu^- e^+$ (B.R. $< 5 \cdot 10^{-10}$); in this case, however, more GPU threads should be allocated for each triplet, allowing for a higher number of hits, and therefore fewer events could be processed simultaneously.\\
%
%LE TRIPLETTE VENGONO FATTE SU CPU, MENTRE ARRIVANO I DATI. DESCRIVERE COSA SUCCEDE DOPO LA SCELTA DELLE TRIPLETTE.