The test setup and the data format used to send data to the GPU will be described in \chaptername~\ref{sect:test-data-format}.\\

In order to store $x$ and $y$ coordinates in 8-\si{\bit} words, as demanded by the data format described in \figurename~\ref{img:dataformat}, we reparametrized the frame enclosing the RICH focal plane in a way that is computationally efficient. Each of the two round flanges hosts 976 photomultipliers distributed on a compact hexagonal lattice (see \figurename~\ref{img:gpu/lattice}). We have assigned a progressive integer to each $x$-axis point occupied by a vertex of the lattice, and another progressive integer to each $y$ position.
As a result, we are effectively defining a lattice where half of the vertices are occupied by the centre of a photomultiplier; this way, a 38$\times$66 lattice is enough to contain all the readout devices of a flange, 
% the whole photomultiplier flange, 
whose coordinates can therefore be represented by two 8-\si{\bit} integers. The two flanges are equal and will be superimposed in the process of ring fitting, therefore only one 38$\times$66 lattice is needed. \figurename~\ref{img:gpu/reparametrization} shows a reparametrized RICH flange.\\

\begin{figure}[t]
\centering
\includegraphics[width=0.75\textwidth]{Images/pdf/gpu_algo/hexagonal_packing_bw}
\caption{Hexagonal packing of circles. Circle centres are spaced by $\Delta x = 1/2$ in $x$, and by $\Delta y = \sqrt{3}/2$ in $y$. If $\Delta x$ and $\Delta y$ represent the gaps in a lattice, half of the lattice points can host the centre of a circle \cite{hexlattice}.}\label{img:gpu/lattice}
\end{figure}

\begin{figure}[t]
\centering
\includegraphics[width=1.05\textwidth, trim= 1.2cm 0cm 0cm 0cm]{Images/pdf/gpu_algo/flangia}
\caption{Representation of the reparametrized RICH photomultiplier-holding flange. The first frame shows the new PMTs coordinates, while the second one shows the lattice that is used for GPU operations: vertical distances are increased by a factor $\sqrt{3}$ because of the filling characteristics of the compact hexagonal lattice.}\label{img:gpu/reparametrization}
\end{figure}

Coordinate reparametrization is operated through the following formulas:
\begin{align}
&x'(x) = \text{round} \left( n_x \;\frac{x - x_{min}}{x_{max} - x_{min}} \right)\label{eqn:8bit-x}
\end{align}
\begin{align}
&y'(y) = \sqrt{3} \cdot \text{round} \left( n_y \;\frac{y - y_{min}}{y_{max} - y_{min}} \right)\label{eqn:8bit-y}
\end{align}
with
\begin{align}
&x_{min} = 0\notag\\
&x_{max} = 66\notag\\
&y_{min} = 0\notag\\
&y_{max} = 38\notag 
\end{align}
so that the centre of each PM, residing in $(x,y)$ in the laboratory frame, is represented by a $(x',y')$ pair in the reparametrized frame. The roundings are used to ensure that the output is the closest integer, rather than using truncations. The vertical coordinates are inflated by a factor $\sqrt{3}$ in order to account for the asymmetrical filling factors of a compact hexagonal lattice. The transformation can be inverted, obtaining:
\begin{align}
&x(x') = x_{min} + \frac{x_{max} - x_{min}}{n_x} \; x'\\
&y(y') = y_{min} + \frac{y_{max} - y_{min}}{\sqrt{3}\;n_y} \; y'
\end{align}
The above conversion formulas prove useful to cast the results back in the laboratory frame. If the program will return the coordinates $(a',b')$ of the centre and the radius $r'$ for each ring, the true values for these parameters can be obtained simply by computing
\begin{align}
&a = x(a')\\
&b = y(b')\\
&r = \frac{x_{max} - x_{min}}{n_x} \; r'
\end{align}

The last formula is obtained making use of the equivalence between the two factors
\begin{align}
&\frac{x_{max} - x_{min}}{n_x} \simeq \frac{y_{max} - y_{min}}{\sqrt{3}\;n_y} \simeq 9
\end{align}
(up to the small rounding needed to cast the laboratory coordinates as the closest integers), that describes the scaling between rescaled and laboratory coordinates, and computing the distance between the centre and one point of the circle:
\begin{align}
&\left\lbrace\begin{array}{l}
x' = a' + r' \cos \theta\\
y' = b' + r' \sin \theta
\end{array}\right. \quad \underrightarrow{\quad\theta \equiv 0\quad} \quad \left\lbrace\begin{array}{l}
x_0' \equiv a' + r'\\
y_0' \equiv b'
\end{array}\right.
\end{align}
Here $\theta$ is an arbitrary phase, that we set to 0 for simplicity. This point corresponds, in the laboratory frame, to the point $\left( x\left(a' + r'\right), y\left(b'\right) \right)$. The distance to the centre will then be:
\begin{align}
r^2 &=\left[ x(a') - x(a' + r') \right]^2 + \left[ y(b') - y(b') \right]^2\\
 &= \left[ x(a') - x(a' + r') \right]^2\\
r &= \big| x(a') - x(a' + r') \big| = \frac{x_{max} - x_{min}}{n_x} \; r'
\end{align}