The timing of each PMT signal is determined using CAEN V1290 high
resolution TDCs in combination with leading edge discriminators.
Taking advantage of the two detector planes with their paddles oriented
perpendicular to each other it is possible to do the timing calibration in
internally consistent way without any reference to an external detector.
The calibration proceeds in several steps by determining timing offsets
for mean-time (MT) and time-difference (TD) of all paddles with PMTs on
both ends with respect to one paddle of arbitrary choice. However, the
very first step is to correct for time-walk.
%
\subsection{Time Walk Correction}
The signal from each PMT is split into two equal amplitude signals, and
while one signal is directly digitized with custom flash ADCs~\cite{Dong1} at a
sample rate of 250~MHz, the second signal is passing through a
discriminator and the timing of the resulting logical signal is measured
with respect to the DAQ trigger~\cite{Cuevas1} using a high resolution TDC.
This timing measurement depends on the signal
amplitude due to the use of a simple leading edge discriminator threshold.
The signal time with respect to the trigger is also determined on the flash
ADC FPGA with a constant fraction discriminator algorithm at somewhat lower
timing resolution, however, accurate enough to be used in finding the walk
correction for the TDC time. In figure~\ref{walkcorr} the time difference between the flash
ADC and the TDC is plotted as a function of the signal integral from the ADC. In this particular
example for the lower end PMT of paddle 8 of the horizontally segmented plane.
\begin{figure}[h]\label{walkcorr}
\begin{center}
\includegraphics[height=8cm]{figures/walk_correction_pl1_pad8_side1_run3180.pdf}
\caption{}
\end{center}
\end{figure}
The detector walk effect is most pronounced for signals with small amplitudes that are
comparable to the discriminator threshold.
The functional from that is used to fit this distribution is represented by the red curve
in the plot and is given by $f(x) = c_1 + c_2*x^{c_3}$. The most important parameter
is $c_3$ and is on average about -0.75. An arbitrary reference value of $x= 14000$ has been
chosen and all times for each individual PMT are corrected to this signal integral.
%
\subsection{Mean Time Offsets}
The mean-time of a detector paddle ($i$) is calculated as the sum of the times from both paddle ends
divided by two:
\begin{equation}
MT^i = \frac{(t^i_{right}+t^i_{left})}{2}
\end{equation}
This value is proportional to the time it took the particle from the vertex to reach the paddle.
Each paddle in a plane overlaps with 42 paddles from the other plane that are oriented perpendicular
to it. If a particle passes through both planes the mean-time from the two paddles of opposite planes
is the same modulo the distance between that two planes which is a constant and can be arbitrarily set
to zero. Selecting hits in a given paddle calculating its mean-time and subtracting the calculated
mean-time from the paddle in the other plane, if hit, and plotting this value with respect to the
paddle number leads to a two dimensional distribution that contains the mean-time offsets of a given
paddle ($ref$) with all the paddles ($i$) from the other plane. This 2-dimensional distribution is
shown for paddle 8 as reference paddle in figure~\ref{meantime} together with a projection of the
5th paddle and the its fit to find the location of the offset of the mean time difference. In the first
plot the vertical axis labels the paddle number in the other plane while the horizontal axis represents the mean time
difference $MT^i - MT^{ref}$.
%
\begin{figure}[h]\label{meantime}
\begin{center}
\includegraphics[height=4.5cm]{figures/mtdiff_vs_padnum_RefPad8_RefPlane0_run9999.pdf}
\includegraphics[height=4.5cm]{figures/mtdiff_vs_padnum_proj_5_ref8_RefPlane0_run9999.pdf}
\caption{Mean-time difference between reference paddle 8 and all other paddles in the other plane (left).
Mean-time difference between paddle 5 and the reference paddle 8(right).}
\end{center}
\end{figure}
These mean-time differences can be evaluated using any paddle as reference paddle in a given plane. Therefore
it establishes a relation between different reference paddles $j$ and $k$. Hence any paddle of a
given plane can be referenced to any other paddle of the same plane by comparing the mean-time
differences with the paddles of the other plane to each other
\begin{equation}
c_{jk} = \frac{1}{N}\sum_{i=1}^{N} (MT^i - MT^{ref_j}) - (MT^i - MT^{ref_k}).
\end{equation}
Rather than evaluating the normalized sum, a distribution of all the differneces is generated and then fit to a Gaussian
to calculate the mean that represents the relative timing offset between the two reference paddles $j$ and $k$
where one reference paddle in the plane chosen to be fixed. In this case paddle 18 of the first plane was
arbitrarily chosen. As an example, the distribution
of the mean-time differences of differences between reference paddle 10 and 18 is shown in figure~\ref{refpaddlediff}.
\begin{figure}[h]\label{refpaddlediff}
\begin{center}
\includegraphics[height=6cm]{figures/meantime_average_to_refpaddle10.pdf}
\caption{Distribution of the difference of the mean-time difference between two reference paddles 10 and 18.}
\end{center}
\end{figure}
At this stage of the calibration offsets for the mean-time of all double-ended readout paddles have been determined
with respect to an arbitrarily chosen paddle, which in this case is paddle 18 of the first plane.
%
\subsection{Time Difference Offsets}
The second quantity that can be evaluated from the doubled-ended readout paddle is the time difference. This
quantity is proportional to the position where the particle passed through the paddle. The difference is
defined in such a way that positive values coincide with positive coordinates. The positive z-axis is along the beam
while the positive x-axis points to the left facing in beam direction. To have a fully right handed system the
positive y-axis points to the sky when facing in beam direction.
\begin{equation}
TD^i = \frac{(t^i_{right}-t^i_{left})}{2}
\end{equation}
This quantity is proportional to the x-coordinate if the paddle is horizontal and to the y-coordinate if the paddle
is oriented vertical.
Similar as in the previous step we take advantage of the fact that for a given paddle the paddles in the other plane
are oriented perpendicular to it and the geometric location of these paddles are related to the time difference of this
reference paddle. A 2-dimensional distribution is generated where for each hit in the reference paddle the
time-difference (TD) is calculated and for each hit found in a paddle of the other plane this value is plotted against
those paddle numbers. The resulting distribution for reference paddle 10 is shown in figure~\ref{timediff} indicating
a clear relation between time-difference and location. Each paddle can be related to the time-difference as indicated
in the right plot.
\begin{figure}[h]\label{timediff}
\begin{center}
\includegraphics[height=4.5cm]{figures/paddleNumber_vs_deltatRefPad10_run9999.pdf}
\includegraphics[height=4.5cm]{figures/deltat_fitposition_p31_repad10_plane1.pdf}
\caption{Left, time-difference for reference paddle 10 as a function of paddle number by hits in paddles
of the other plane. Right, time-difference location with respect of paddle 31.}
\end{center}
\end{figure}
The central four paddles have a width of 3~cm, which is half of all the other paddles. This causes the wiggle of
the distribution in the central region. Identifying the paddle numbers with their geometric position in the
TOF wall, the measured time-differences can be related to positions along the paddle and an effective light
velocity can be extracted with a linear fit to the data (see Fig.~\ref{velocity}). The effective velocity
is the inverse of the slope. In the current example of paddle 10 in the first plane
this velocity is found to be $15.655 \pm 0.003 \frac{cm}{ns}$. The uncertainty is statistical only, the
systematic uncertainty is much larger.
\begin{figure}[h]\label{velocity}
\begin{center}
\includegraphics[height=6cm]{figures/paddleNumber_vs_deltatRefPad10_run9999.pdf}
\caption{Effective velocity determination using the relation between time-difference and paddle positions.}
\end{center}
\end{figure}
The average effective velocity of all paddles is found to be $15.67\frac{cm}{ns}$ with a sigma of $0.16\frac{cm}{ns}$
which translates into a systematic uncertainty of about 1\%.
The constant in the linear fit to the data represent the offset of the time-difference as a perfectly calibrated
paddle would lead to a zero time difference at the center of the paddle. Repeating this procedure for each
double-ended readout paddle leads to time-difference offsets for all these paddles.
\subsection{PMT Timing Offsets}
At this stage in the calibration offsets have been determined for mean-time and time-difference of all paddles
that have a PMT on both ends. With this information individual timing offsets for each PMT can be calculated using
MT and TD. For each paddle $i$ in plane $j$ the offsets for PMT left($L$) and right($R$) is given by
\begin{eqnarray}
PMT^{i,j}_{L} &=& MT^{i,j} - TD^{i,j}, \\
PMT^{i,j}_{R} &=& MT^{i,j} + TD^{i,j}.
\end{eqnarray}
Note that one paddle serves as global reference and hence its MT is chosen to be zero. This will result in a global
timing shift that can be corrected for in the last step of the calibration.
To test the quality of the calibration at this point these timing offsets are used to calculate the
mean-time differences
between a reference paddle and all the double-ended paddles in the other plane intersecting with the reference
paddle. In order to minimize background only events with tracks of particles with momenta larger than 1.0~GeV/c
that hit the TOF wall are considered. The required overlap of the paddles with the track intersecting the TOF
wall are set very loose ($\pm 12$~cm) in order to minimize any bias. The result is shown in figure~\ref{calibapply}
for reference paddle 11.
\begin{figure}[h!]\label{calibapply}
\begin{center}
\includegraphics[height=4.5cm]{figures/mt_diff_paddle11_calibrated.pdf}
\includegraphics[height=4.5cm]{figures/mt_diff_fullTOF.pdf}
\caption{Mean-time difference between reference paddle 11 and all paddles from the other plane with calibration
parameters applied (left). Mean-time difference distribution of all paddles in the detector (right).}
\end{center}
\end{figure}
The distribution is well centered around zero for all paddles with a sigma of 136~ps assuming a Gaussian distribution.
This results in a timing resolution for an individual paddle of about 96~ps.
It is now possible to calibrate the single-ended readout paddles. Particle tracks with momenta larger than 1.0~GeV/c
are selected that pass through the central region of the innermost full paddles (paddle 20 and 21). These paddles
have half width ($3$~cm). A time difference in these paddles
of $\pm 0.5$~ns is required which corresponds to a distance of $\pm 7.6$~cm around the center, covering the two
single-ended paddles left and right of the central axis of the TOF planes. These single-ended readout paddles are
$6$~cm in width. For these events the mean-time is calculated and subtracted from the time of the single-ended paddle
PMT time.
\begin{equation}
\delta_t = T_{single} - MT^{21,20}
\end{equation}
The distribution of these time differences is peaking for correlated events where the track passes tough both
planes. The position of this peak in time give directly the timing offset for this PMT signal. With this step
timing offsets are determined for all eight single-ended readout paddles in the two TOF planes and timing
offsets for all PMT signals have been determined. In a last step the mean of the distribution of all these
timing offsets is determined and this mean value is subtracted from all the offset parameters. In this way the
calibration is not only internally consistent but also does not change the overall timing of the TOF detector with
respect to any other detector in the system.