%This thesis reports two different aspects of the same project. A previous stage of validation and characterisation was necessary before turning to the development of an actual trigger algorithm. Therefore, this document is organized in parts.\\
%
%Part~\ref{part1} presents the NA62 experiment, in which scope this work was carried out. \chaptername~\ref{ch:na62} outlines its main Physics objective, that is the study of the ultra-rare decay $K^+ \rightarrow \pi^+ \nu \bar{\nu}$. The theoretical framework and Physics sensitivities of this process are discussed, and a brief report is given about the previous searches for this decay. \chaptername~\ref{ch:exp-setup} introduces the NA62 detector, discussing the characteristics of the high-energy beam used to provide kaon decays, and analysing the purpose and layout of the various sub-detectors.\\
%
%In Part~\ref{part2} I report the results of my feasibility study, with an evaluation of the maximum rejection efficiency reachable with a ring-finding trigger. \chaptername~\ref{ch:purpose} describes the current trigger chain in development for the NA62 experiments, and discusses the benefits of using commercial graphic processors (GPUs) at the earliest trigger stages. In this chapter I also set and explain the objectives of my thesis work. In \chaptername~\ref{ch:reco} I will introduce the software framework I used for all simulations. The reconstruction procedure I developed to extract Physics information from RICH data will be discussed in detail. The outcome of this work is reported in \chaptername~\ref{ch:mc}, where I explore several possible designs for a direct rejection trigger for $\pi^+ \pi^0$ events.\\
%
%Finally, in Part~\ref{part3} I will describe how I implemented the actual GPU trigger, and report the subsequent efficiency and timing tests. \chaptername~\ref{ch:tolomeo} gives a general description of the multi-ring algorithm we designed, divided in a pattern recognition step and a single-ring fit, and reports the preliminary tests I did in order to chose the best single-ring fitting algorithm available. In \chaptername~\ref{app:algo-implementation} I will introduce the CUDA toolkit, and I will go through the technical details of the GPU algorithm, including some pieces of code. Test of the functioning and of the timing of the program were performed, whose results are reported and examined in \chaptername~\ref{ch:tests}. Here I also sum up the status of this work and discuss what conclusions can be drawn from this experience.\\
%
%I felt the need to devote some pages to the mathematical analysis of the main single-ring fit methods I used. Appendix~\ref{app:fits} represents a brief introduction to the problem of circular regression, and describes two different algebraic algorithms.


This thesis deals with two different aspects of the same project. A preliminary stage of validation and characterisation was in fact necessary before starting the development of an actual trigger algorithm. Therefore, this document is organized in parts. My own work is described in Parts~\ref{part2} and~\ref{part3}.\\

%This thesis is organized in parts reporting different aspects of the same project. My own work is described in Parts~\ref{part2} and~\ref{part3}. A preliminary stage of validation and characterisation was necessary before starting the development of an actual trigger algorithm.\\% Therefore, this document is organized in parts.\\

Part~\ref{part1} presents the NA62 experiment, in the contest of which this work was carried out. \chaptername~\ref{ch:na62} outlines the main Physics goal, that is the study of the ultra-rare decay $K^+ \rightarrow \pi^+ \nu \bar{\nu}$. The theoretical framework and Physics sensitivities of this process are discussed, and a brief report is given about the previous searches for this decay. \chaptername~\ref{ch:exp-setup} focusses on the NA62 detector, discussing the characteristics of the high-energy beam used to provide kaon decays, and analyses the purpose and layout of the various sub-detectors.\\

In Part~\ref{part2} I describe the results of my feasibility study, with an evaluation of the background rejection efficiency of a trigger based on the identification of \v{C}erenkov rings. \chaptername~\ref{ch:purpose} describes the trigger chain for the NA62 experiment, and discusses the benefits of using commercial graphic processors (GPUs) at the earliest trigger stage. In this chapter I also set and describe the objectives of my thesis work. In \chaptername~\ref{ch:reco} I introduce the software framework used for all simulations. The reconstruction procedure I developed to extract physics information from RICH data is discussed in detail. The outcome of this work is reported in \chaptername~\ref{ch:mc}, where I explore several possible designs for a direct rejection trigger for $\pi^+ \pi^0$ events.\\

Finally, in Part~\ref{part3} I describe how I implemented the actual GPU trigger, and report on its efficiency and timing tests. \chaptername~\ref{ch:tolomeo} presents a general description of the multi-ring algorithm we designed, divided in a pattern recognition step and a single-ring fit, and reports the preliminary tests I did in order to choose the best single-ring fitting algorithm available. In \chaptername~\ref{app:algo-implementation} I briefly introduce the CUDA toolkit, and I go through the technical details of the GPU algorithm, including some pieces of code. Tests of the program functioning and timing have been performed, whose results are reported and examined in \chaptername~\ref{ch:tests}. There I also sum up the present status of this work and discuss the conclusions which may be drawn from this experience.\\

I thought it useful to devote some pages to the mathematical analysis of the main single-ring fitting methods I used. Appendix~\ref{app:fits} is a brief introduction to the problem of circular regression, and describes two different algebraic algorithms. The code with which I implemented the chosen fitting method in the trigger algorithm is available in Appendix~\ref{app:taub-code}. Finally, Appendix~\ref{app:devicequery} lists useful specifications of the specific graphic card used to implement and test the trigger.